-
Notifications
You must be signed in to change notification settings - Fork 197
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
LRU Eviction Policy #503
base: master
Are you sure you want to change the base?
LRU Eviction Policy #503
Conversation
Interesting! I assume this patch is to make it easier to use APCu as a general purpose in-memory cache. If so, we ended up having to optimize for that case recently, but we ended up taking a slightly different approach—we just tweaked In either case, from an end-user perspective, I'm not sure if this behavior should be gated behind a config flag—it could create additional complexity as distributions and other packagers would end up making the decision whether to use APCu with LRU functionality or not. I think this is better suited to be an INI flag instead, so that APCU end-users, not distribution package maintainers, can configure how their cache behaves. What do you think? |
@mszabo-wikia I think your approach is simple yet effective. However, if all entries are active (not expired) and the shared memory is full, all entries will be deleted due to In this implementation, I used config flag to reduce extra memory consumption on |
Great idea! I wanted LRU for APCu since quite a long time. |
I added a new configuration item |
That's great, thank you! |
…s (like apc_cache_entry_t)
In this implementation, whenapcu_store
,apcu_add (only on successful addition)
,apcu_fetch
,apcu_entry
,apcu_inc
,apcu_dec
,apcu_cas
are used, the access history is updated.If the allocation of shared memory fails, the oldest entries in the access history will be deleted.
To enable function, specify
./configure --enable-apcu-lru
.This is the implementation of the LRU eviction policy.
In this implementation, the access history is updated when using
apcu_store
,apcu_add (only on successful addition)
,apcu_fetch
,apcu_entry
,apcu_inc
,apcu_dec
, andapcu_cas
, and when memory allocation fails, the cache entries are evicted in order of the oldest access history.To enable this feature, set the configuration parameter
apc.eviction_policy
tolru
(the default value isdefault
, which is the conventional behavior).Additionally, by setting
apc.smart
, it is possible to adjust the amount of the cache entries to be evicted (the required size for allocation *apc.smart
will be evicted).