Caching POA #1454
Caching POA #1454
Conversation
Signed-off-by: Darko Kulic <darko.kulic@evernym.com>
pub extern fn indy_get_cred_def(command_handle: IndyHandle, | ||
pool_handle: IndyHandle, | ||
wallet_handle: IndyHandle, | ||
submitter_did: *const c_char, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I suggest to remove submitter_did param as it can be hard-coded or auto-generated for each request
- Do we need to return cache timestamp also?
- I suggest to add options_json that will allow to:
- Skip caching
- Provide required freshness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Skip caching have sense in a meaning do not store retrieved value inside of cache.
For freshness, I think that schema and credential_def cannot be updated (without change of id) so freshness is not needed. For that reason I do not see need for cache timestamp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my understanding CredDef and Schema can be updated. Schema can get backward compatible changes. Keys in CredDef can be rotated in some cases. Also some entities we plan to cache like DID Doc can be updated much often. @ashcherbakov What do you think?
Signed-off-by: Darko Kulic <darko.kulic@evernym.com>
docs/design/013-caching/README.md
Outdated
|
||
Several methods may be implemented for purging the cached data: | ||
|
||
#### Purge all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we need to decide what exact option to use or provide an API for configuration of cache. For example, we can add behavior configuration to indy_init() method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To define purge behavior i also suggest to look to http cache options:
Cache-Control: max-age=<seconds>
Cache-Control: max-stale[=<seconds>]
Cache-Control: min-fresh=<seconds>
Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: no-transform
Cache-Control: only-if-cached
In this case we can define exact behavior for each entity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkulic @jovfer @ashcherbakov @dhh1128 What do you think on ^?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I follow your thoughts regarding defining exact behavior for each entity. Do you mean adding specific caching policy to each entity, so that purging process may selectively purge only entities which satisfy its own policy? If this is the case, that seams to complicated...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkulic The idea is very simple:
- When app asks for some entity it can explicitly say how long it want to store this entity in cache
- On start app can call
purge
method that will remove all outdated records.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds doable. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also purge can have force
param that will remove all cache records.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the timeout idea, because you may lock in some cache items in cache forever. (eg. so you may use your passport on foreign airport, without internet).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some thoughts I figured out I do not like idea about purging on start/specifying ttl for every entity. I would expect that normally you would want data to be in cache for longer time, so you may during request choose max-age of data you want. I would modify it like this:
- When requesting a data, app may use some cache control options (like max-age, no-cache, no-store, only-if-cached, for eg.)
- purge method would have option of specifying max-age (or similar), so older data would be deleted.
/// id: identifier of credential definition. | ||
/// options_json: | ||
/// { | ||
/// forceUpdate: (optional, false by default) Force update of record in cache from the ledger, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can use something similar to http-cache control headers:
Cache-Control: max-age=<seconds>
Cache-Control: max-stale[=<seconds>]
Cache-Control: min-fresh=<seconds>
Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: no-transform
Cache-Control: only-if-cached
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these options look very useful. I would like not to have too many options, which may be too confusing. I especially like: max-age, only-if-cached.
Signed-off-by: Darko Kulic <darko.kulic@evernym.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the latest changes around cache lifetime. I'm voting to merge this design, implement it in code but mark experimental for the next one release
Signed-off-by: Darko Kulic darko.kulic@evernym.com