what is the key name generation rule
flyly0755 opened this issue · 4 comments
":1:views.decorators.cache.cache_header..[a string of characters].en-us.UTC"
For example a key like above, why start with :1, what meaning of the number 1?
:views.decorators.cache.cache_header seems like some path tier.
then with a string of characters which length is 32, i think it's something like uuid, but base what to generate this string?
and with suffix .en-us.UTC, seems every key ends with it, what's the point with en-us.UTC suffix?
If without en-us.UTC this suffix, the key is more short, which i think is more quick to query from redis with key
:1:views.decorators.cache.cache_header..[a string of characters] instead of
:1:views.decorators.cache.cache_header..[a string of characters].en-us.UTC.
":1:views.decorators.cache.cache_header..[a string of characters].en-us.UTC" For example a key like above, why start with :1, what meaning of the number 1? :views.decorators.cache.cache_header seems like some path tier. then with a string of characters which length is 32, i think it's something like uuid, but base what to generate this string? and with suffix .en-us.UTC, seems every key ends with it, what's the point with en-us.UTC suffix? If without en-us.UTC this suffix, the key is more short, which i think is more quick to query from redis with key :1:views.decorators.cache.cache_header..[a string of characters] instead of :1:views.decorators.cache.cache_header..[a string of characters].en-us.UTC.
found out :1: indicates which redis database:)
the 1 in :1:...
is the version of the cached value if you look at DefaultClient.make_key
function here and then the default make_key in django here you will see that the version is the second argument and key prefix is by default an empty string.
Also please when posting an issue, put a snippet of code so that it can be easier to understand any issue
the 1 in
:1:...
is the version of the cached value if you look atDefaultClient.make_key
function here and then the default make_key in django here you will see that the version is the second argument and key prefix is by default an empty string.Also please when posting an issue, put a snippet of code so that it can be easier to understand any issue
got it, thx!
But I have other doubt
:2:views.decorators.cache.cache_header..bc501908301912xyz8354c68dcc4dd84.en-us.UTC
bc501908301912xyz8354c68dcc4dd84 this string is how generated? related with time stamp?
Combine with UTC suffix(may also end with UTC+8 and so on) can calculate time stamp of this key first generated?
without seeing a code sample it is hard for me to help.
Assuming you used @cache_page
decorator and that you did not override any of the settings take in CacheMiddleware
that you can find here, the cache key is given from the function learn_cache_key
that you can find here and the last part is given from _i18n_cache_key_suffix
function that you can find here.
Probably you have USE_I18N
and USE_TZ
set to True