Giter VIP home page Giter VIP logo

Comments (2)

fjsj avatar fjsj commented on August 15, 2024

Hi SantjagoCorkez,

I think you can't just strip self out from the cache_key, since different instances probably will return different values even for the same method. I believe this is the default use case.

Probably in your case you need something different from this, so I think you can create your own decorator around cache_it decorator. If you need help for doing this, please let me know.

from redis-simple-cache.

SantjagoCorkez avatar SantjagoCorkez commented on August 15, 2024

Well, in my case the solution just strips out the first function arg. No matter what is it: self, cls or any generic argument as in staticmethod. And this guarantees no side effects in my case, because instance's self contains no information that could cause difference between instance of class A(B) and class C(B), where B inits only logger.

As I've said, that could be specially marked in documentation as 'think twice when you use this argument'.

As for more generic solution this could be also implemented as strip_args=0 argument for decorator and pickle.dumps(args[strip_args:]) in code. That could help when one needs to exclude some N-first args of a function from cache entry's hash key.

from redis-simple-cache.

Related Issues (14)

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.