Git Product home page Git Product logo

lru_redux's People

Contributors

aaronlasseigne avatar bryant1410 avatar makinada avatar samsaffron avatar seberius avatar tjsingleton 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lru_redux's Issues

TTL cache name space feedback.

With the addition of a new cache I wanted to get some feedback on the current working name for the TTL cache. I also included an alternative naming scheme to consider.

# Current
LruRedux::Cache
LruRedux::ThreadSafeCache

# Working TTL names
LruRedux::TtlCache
LruRedux::ThreadSafeTtlCache

# Alternative
LruRedux::LRU::Cache
LruRedux::LRU::ThreadSafeCache

LruRedux::TTL::Cache
LruRedux::TTL::ThreadSafeCache

If the modularized name space was chosen, the current namespaces LruRedux::Cache and LruRedux::ThreadSafeCache could be made into a subclass to provide identical functionality (and backwards compatibility) but also raise a warning about the name change. This is similar to what the 'minitest' gem does if you call MiniTest::Unit::TestCase instead of MiniTest::Test.

use cases

Hi Sam, granted this isn't the best use an a "issue" but i'm wondering if you have an example of how you use this gem with discourse?

I've seen your presentation Off The Rails https://www.youtube.com/watch?v=aP5NNkzb4og but didn't really follow what the benefit of using LRU Cache is in web apps.

Do you have a simple example of where this could be most commonly used?
Thanks
Tim

Hash#reverse is undefined

cache.each {|k,v| p "#{k} #{v}"}
NoMethodError: undefined method `reverse' for {:b=>"2"}:Hash

An alternative would be:
Hash[@data.to_a.reverse]

Ruby Version: 2.0.0p247

Monitoring/Stats?

Is there a reasonable mechanism for monitoring the cache hit ratio of any of the lru_redux caches? I can of course, monitor using booleans etc at the callsite, but it's kinda inconvenient if there are plenty of them.

Would you be interested in a patch that adds stats somehow?

Expiry without eviction

Hi, I was just wondering if there were plans to add an equivalent to the soft_ttl functionality from lrucache, or forced expiry on a timer?

My app hits another server for results which change semi-frequently. I'm caching the results for 30 seconds, but I frequently don't fill the cache to the point things get evicted so they just sit there forever. I'm aware I could have a thread call .expire! every so often, but ideally I'd like to make entries expire when they've been there for a certain amount of time (i.e. force retrieval without them being evicted).

Eviction Callback

Is there any means for executing a callback (lambda/proc/block) when an item is automatically evicted from the cache due to cache size? This is useful in scenarios where necessary cleanup has to occur before dereferencing an object, such as for network connection related matters.

I wish that getset could ignore nil

cache.getset(:foo, ignore_nil: true) { nil }
cache.key?(:foo) == false
cache[:foo] == nil
cache.getset(:foo, ignore_nil: true) { :bar }
cache.key?(:foo) == true
cache[:foo] == :bar

LruRedux::TTL::ThreadSafeCache.delete does not return the deleted item as docs say

The LruRedux::TTL::ThreadSafeCache.delete method does not return the deleted item as docs say. It looks like the code returns an expiration time float value and not the deleted item.

Easy enough to work around, but we need to either update the README docs or change the library's behavior.

Example reproduction:

my_cache = LruRedux::TTL::ThreadSafeCache.new(8, 300)
my_cache["a"] = "This is string A"
my_cache["b"] = "This is string B"

result_obj = my_cache.delete "a"
puts "result_obj: #{result_obj} #{result_obj.class}"

This produces output like:

result_obj: 1697043228.1882849 Float

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.