1

From Flask-Cache Documentation, cached function takes following parameters - timeout,key_prefix, unless. Unless is descibed as

  • unless – Default None. Cache will always execute the caching
    facilities unless this callable is true. This will bypass the caching entirely.

Is there a way to pass parameters to unless function, by which we can dynamically know whether to apply the caching or not.

davidism
  • 121,510
  • 29
  • 395
  • 339
a.m.
  • 2,083
  • 1
  • 16
  • 22
  • What values, precisely, are you expecting this callable to accept as arguments? Remember that Flask-Cache will be calling the callable, so you don't really control what the arguments are. – Mark Hildreth Jan 03 '14 at 22:45
  • 1
    You can access almost everything inside your function through `request` context. I don't know what you want to do with these unless parameters. Can you give an example? – iurisilvio Jan 05 '14 at 22:42
  • Actually accord to some requirements, I wants to disable caching for some particular request(not for the majority ones, but for some). Either I can take arguments as some environment/global variable or as @iurisilvio said by request context also. – a.m. Jan 06 '14 at 04:31
  • 1
    So, you probably don't need these parameters. You have to check these "requirements" in the callable, but they are not passed as parameters, you should access them in some other way. – iurisilvio Jan 06 '14 at 11:16

1 Answers1

2

Looking at the code as it currently stands this is not possible. Definitely worth a pull request.

Sean Vieira
  • 155,703
  • 32
  • 311
  • 293