-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optional data for callback? #17
Comments
If I understand what you want, you can do it without changing the Pylru API. Use a nested function to create a closure, thus capturing any variables the callback function needs. Pass the resulting callback function to Pylru at initialization. If you need an example, look at how I implemented the callback function in WriteBackCacheManager. |
I see your callback is nested the object's init() function. It is able to use attributes of the object. My callback function is nested in a procedure which is not the method of an object, it is just a function. Other than global data (ick) I don't see how to give it the data it needs to perform its function. Something like this occurred to me. Perhaps I didn't understand how to do this with existing code.
|
What you want can be done with the current API. I suggest you learn more about nested functions and closures so that you can create the callback function you require. I am not going to change the API of pylru, when it is not necessary. But, you are always free to fork the source and modify it as you see fit. Best of luck. |
Thanks. I didn't fully grok closures but now I do. All is well. < david On 01/26/2016 10:42 AM, jlhutch wrote:
|
Hi. I want to use pylru in an application and use the callback option. However, my callback would need additional information in order to execute. I would like to hand that information into the init() function as an optional dictionary. The callback would know what to do with it.
Is this feasible or is there already a way to do this that I have missed?
If this is the wrong place to request a feature (or propose a code mod) please let me know. Thanks,
< david
The text was updated successfully, but these errors were encountered: