# Way to cache output from immutable input?

**URL:** <https://discourse.julialang.org/t/way-to-cache-output-from-immutable-input/4204>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 11, 2017, 3:27am UTC](https://discourse.julialang.org/t/way-to-cache-output-from-immutable-input/4204 "2017-06-11T03:27:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [June 11, 2017, 3:27am UTC](https://discourse.julialang.org/t/way-to-cache-output-from-immutable-input/4204/1 "2017-06-11T03:27:38Z")

</div>

Lets say you have code like:

```julia
function foo(x::Float64, scaling::Number=2)
  x * scaling
end

foo(4.0, 1) # unique call

foo(4.0, 1) # repeat call
foo(4.0, 1) # repeat call
foo(4.0, 1) # repeat call

foo(4.0) # unique call
foo(4.0, 2) # unique call

```

Is there a cache system available to store all the repeat calls?

* * *

- in the code above, obviously you could just store it as a variable
- the interesting problem is when they’re called at different levels of a call tree like:
  - `a calls b calls c calls d calls ...`

---

<div class="post-metadata">

**Author:** ![bicycle1885](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bicycle1885/32/107_2.png) [@bicycle1885](https://discourse.julialang.org/u/bicycle1885)\
**Post date:** [June 11, 2017, 3:44am UTC](https://discourse.julialang.org/t/way-to-cache-output-from-immutable-input/4204/2 "2017-06-11T03:44:19Z")

</div>

[https://github.com/simonster/Memoize.jl](https://github.com/simonster/Memoize.jl)?

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [June 11, 2017, 3:45am UTC](https://discourse.julialang.org/t/way-to-cache-output-from-immutable-input/4204/3 "2017-06-11T03:45:05Z")

</div>

whoops, yea…

just saw:

- [Caching function values](https://discourse.julialang.org/t/caching-function-values/2092/1)
