Git Product home page Git Product logo

redis-simple-cache's People

Contributors

allencharp avatar djgilcrease avatar fjsj avatar jmtoball avatar nudge avatar szaydel avatar vivekn 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  avatar

redis-simple-cache's Issues

Allow cache_it* decorators to provide a way to cache instance methods

That'd be a good option to have cache_it() and cache_it_json() either auto-detecting instance methods or being marked of such a use case by, for example, strip_first_arg boolean parameter that'd perform something like

pickle.dumps(args[1:])

There's a side effect in such a use case, I know, but could be an option for those who know what they do.

In my case, using instance methods eliminates a need to call getLogger every time I need to log something and provides an option to use one, instance-wide, logger (which certainly cannot be pickled because of file descriptors inside any logger object).

The prefix depends on the id of the SimpleCache object.

I missed this earlier, but I found that the SimpleCache.make_key() method uses the id of the instance in the key's prefix. The id is determined at runtime, so effectively a new cache is created every time the program is run. If the program is restarted the earlier cache is inaccessible. Is this really a good idea?

@fjsj I would like to hear your views on it.

Optional keyword to forcibly bypass cache

So, in case I'm not understanding things correctly, is there a way to handle the following use case: I have a function which I need to cache most of the time, but in a few very specific cases I need it run its course. The function is grabbing things from a web api, most of these do not change but some do, and that fact only matters in one use case. Can I provide an additional keyword just for that specific use case?

e.g.

get_data(dont_cache=True)

I'm thinking the best place to implement this (in case this doesn't already exist) would be here. Thoughts?

Support python 3

This code currently doesn't work under Python 3. The to_unicode() function, and perhaps other things too.

cache_it and cache_it_json will not properly cache methods that use keyword args

If you wish to cache a method that uses keyword args you need to do it manually instead of using the decorator, which is annoying since it should be a simple fix to add a use_kwargs argument to cache_it that defaults to False, can be True for using all kwargs or can be a comma separated string of kwarg keys to use in the generation of the key

Impossible to select redis db

rediscache.py contains this code:

            self.connection = RedisConnect(host=self.host,
                                           port=self.port,
                                           db=0,
                                           password=password).connect()

so as you can see db is always 0

Cache Initial Conditions [Feature Request]

I am planning to implement initial conditions (seed values). Providing seed values can simplify the body of a recursive function significantly.

I image it looking something like this:

# Fibonacci
@cache_it(seed={0:0, 1:1})
def F(i): return F(i-1) + F(i-2)

Since the seed changes all the values of the function, the seed should be fed into the hash used for the function key.

Are there any other considerations I should take into account before implementation?
Does this sound like it falls within the scope of the goals of this repo?

expire keys

It would be great to implement methods to expire not all keys in set but with specific args and specific functions.

Infinite limit

It would be great to have infinite limit when 'limit' is set to, for example, 0

some ut failed

Hi,

Some ut cases failed, such as:
def test_decorator(self)

Ranges of keys

I think it would be nice to have ranges of keys, which are stored as members of a set. One should be able to define a range of any given name, and optionally add keys for any wrapped function to this set. Any number of sets should be possible. This would make it easier to selectively expire groups of keys prematurely, if necessary. I can see a use case for this being where a change made to some data elements will result in no-longer valid cached entries, but their expiration originally set on the wrapped function or functions has not yet been reached.

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.