Giter VIP home page Giter VIP logo

caching.jl's Introduction

Caching.jl

Memory and disk memoizer written in Julia.

License Build Status Coverage Status

Installation

The installation can be done through the usual channels (manually by cloning the repository or installing it through the julia REPL).

License

This code has an MIT license and therefore it is free.

Reporting Bugs

Please file an issue to report a bug or request a feature.

References

[1] https://en.wikipedia.org/wiki/Memoization

[2] https://en.wikipedia.org/wiki/Cache_replacement_policies

For other caching solutions, check out also LRUCache.jl, Memoize.jl and Anamnesis.jl

caching.jl's People

Contributors

juliatagbot avatar uriele avatar zgornel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

caching.jl's Issues

caching function that returns mutable produces confusing behaviour

Unclear how to fix this nicely - maybe you want your function to return a reference to the same mutable struct each time and you don't mind that the contents of that struct has changed between function calls?

In my case I've just split my function up so I can cache the immutable string I get from a glorified HTTP.get() operation and I parse the string into a Dict later.

Anyway, I think this should maybe be documented?

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Persistence Problem

I expect to be able to reuse a cache persisted to disk. To simulate restarting julia, etc., (and because my use case will involve a wrapper function that will get redefined anyways) I define a new function to test it but that fails.

Steps to reproduce:

using Caching, Unitful, Logging
using Unitful: V, A

# turn on debug output
global_logger(ConsoleLogger(stderr, Logging.Debug))

# create cache entries and sync
power(U::Unitful.Voltage, I::Unitful.Current) = U * I
cache = Caching.Cache(power; name="power", filename="cache-power.bin")
cache(1V, 1A)
syncache!(cache; with="both")

# now try to reuse the cache
power2(U::Unitful.Voltage, I::Unitful.Current) = U * I
cache2 = Caching.Cache(power2; name="power", filename="cache-power.bin")
syncache!(cache2; with="both")
cache2(1V, 1A)

The output indicates that cache2 is empty and the function call to it produces a "Full cache miss." Am I using Caching incorrectly, or is this a bug?

@warn Messages should be @debug instead

I'm trying to use this interesting package but all the cache-miss (and even cache file creation) warnings annoy me. I like to reserve a warning to something likely to be a user error, so a cache miss IMHO should be a @debug, and a cache file creation at most a @info.

Could this behavior be changed, perhaps?

Caching ignores the order of function arguments?

julia> @cache function foo(a, b)
           return a
       end
foo (cache with 0 entries, 0 in memory 0 on disk)

julia> foo(1, 2)
1

julia> foo(2, 1)
1

julia> foo
foo (cache with 1 entry, 1 in memory 0 on disk)

Package broken on 1.8.3?

Just tried using this package and it seems broken, can't reproduce the documentation example

julia> using Caching

julia> @cache function foo(x)
           x+1
       end
foo (cache with 0 entries, 0 in memory 0 on disk)

julia> foo(11)
ERROR: MethodError: no method matching return_type(::typeof(f_ZdEZpTn9hmuyAFW1PBY3), ::Tuple{DataType})
Closest candidates are:
  return_type(::Any, ::DataType) at compiler/typeinfer.jl:1019
  return_type(::Any, ::DataType, ::UInt64) at compiler/typeinfer.jl:1025
Stacktrace:
 [1] (::Cache{typeof(f_ZdEZpTn9hmuyAFW1PBY3), Any, CountSize})(args::Int64; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Caching ~/.julia/packages/Caching/ifvU9/src/cache.jl:121
 [2] (::Cache{typeof(f_ZdEZpTn9hmuyAFW1PBY3), Any, CountSize})(args::Int64)
   @ Caching ~/.julia/packages/Caching/ifvU9/src/cache.jl:88
 [3] top-level scope
   @ REPL[4]:1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.