Skip to content

Commit 00fe89a

Browse files
committed
added noisy caching
1 parent c9fb01d commit 00fe89a

File tree

5 files changed

+6
-4
lines changed

5 files changed

+6
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DynamicObjects"
22
uuid = "23d02862-63fe-4c6e-8fdb-1d52cbbd39d5"
33
authors = ["Nikolas Siccha <nikolassiccha@gmail.com> and contributors"]
4-
version = "0.1.3"
4+
version = "0.1.4"
55

66
[deps]
77
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

examples/_freeze/index/execute-results/html.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"hash": "a8d44e1cc76ceca449deaae046e72284",
2+
"hash": "a030b219fc18d58b27547d2267b43c0f",
33
"result": {
4-
"markdown": "---\ntitle: Geometry example\nexecute:\n daemon: 999999\n---\n\n::: {.cell execution_count=1}\n``` {.julia .cell-code}\nusing DynamicObjects\n\n\"\"\"\nA common base type for shapes.\n\"\"\"\n@dynamic_type DynamicShape\n\ndescription(what::DynamicShape) = \"A $(what) has an area of $(what.area).\"\n\n\"\"\"\nA fancy rectangle.\n\"\"\"\n@dynamic_object Rectangle <: DynamicShape height::Number width=1 \narea(what::Rectangle) = what.height * what.width\n\n\"\"\"\nA boring circle.\n\"\"\"\n@dynamic_object Circle <: DynamicShape radius::Number\narea(what::Circle) = what.radius^2 * pi \n\nprintln(Rectangle(10).description)\nprintln(Circle(20).description)\nCircle(20) \n```\n\n::: {.cell-output .cell-output-stdout}\n```\nA Rectangle(height = 10, width = 1) has an area of 10.\nA Circle(radius = 20,) has an area of 1256.6370614359173.\n```\n:::\n\n::: {.cell-output .cell-output-display execution_count=15}\n```\nCircle(radius = 20,)\n```\n:::\n:::\n\n\n",
4+
"markdown": "---\ntitle: Geometry example\nexecute:\n daemon: 999999\n---\n\n::: {.cell execution_count=1}\n``` {.julia .cell-code}\nusing DynamicObjects\n\n\"\"\"\nA common base type for shapes.\n\"\"\"\n@dynamic_type DynamicShape\n\ndescription(what::DynamicShape) = \"A $(what) has an area of $(what.area).\"\n\n\"\"\"\nA fancy rectangle.\n\"\"\"\n@dynamic_object Rectangle <: DynamicShape height::Number width=1 \narea(what::Rectangle) = what.height * what.width\n\n\"\"\"\nA boring circle.\n\"\"\"\n@dynamic_object Circle <: DynamicShape radius::Number\narea(what::Circle) = what.radius^2 * pi \n\nprintln(Rectangle(10).description)\nprintln(Circle(20).description)\nCircle(20) \n\nDynamicObjects.cached(Circle(20), :area)\n```\n\n::: {.cell-output .cell-output-stderr}\n```\n┌ Info: Precompiling DynamicObjects [23d02862-63fe-4c6e-8fdb-1d52cbbd39d5]\n└ @ Base loading.jl:1664\n```\n:::\n\n::: {.cell-output .cell-output-stdout}\n```\nA Rectangle(height = 10, width = 1) has an area of 10.\nA Circle(radius = 20,) has an area of 1256.6370614359173.\n```\n:::\n\n::: {.cell-output .cell-output-display execution_count=2}\n```\n1256.6370614359173\n```\n:::\n:::\n\n\n",
55
"supporting": [
66
"index_files"
77
],
17 Bytes
Binary file not shown.

examples/index.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ area(what::Circle) = what.radius^2 * pi
3030
println(Rectangle(10).description)
3131
println(Circle(20).description)
3232
Circle(20)
33+
34+
DynamicObjects.cached(Circle(20), :area)
3335
```

src/DynamicObjects.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function cached(what, key)
154154
# println("LOADING FROM FILE!")
155155
Serialization.deserialize(file_name)
156156
else
157-
# println("COMPUTING")
157+
println("Writing result to $(file_name)!")
158158
rv = getproperty(what, key)
159159
Serialization.serialize(file_name, rv)
160160
rv

0 commit comments

Comments
 (0)