#69 problems updating values when shared memory is full

open
nobody
None
5
2003-11-26
2003-11-26
Raide
No

We use mmcache in our php CMS application, via a set of
wrapper functions we have created which maintain an
array of values in memory, this array is in the cache
and is called 'map' and allows us to cleanup unused
objects in memory.

Whenever we add a value to memory, our wrapper
functions do an mmcache_lock('map');
mmcache_get('map'), the key for the new data is added
to the map, and the map is put back with mmcache_put()
and then unlocked.

The issue we have is when the shared memory cache is
full, and the 'map' array is in shared memory, we open
the map to add our new value to it, then add the value
into the cache. (because shm is full the new value goes
into the filesystem) however the map, which was in
shared memory when it is written back mmcache_put()
returns true, but it has not updated the map in memory
at all.

Without having read through the mmcache source I'm just
guessing, but I think that if a value is in shared
memory and memory is full, and I try to update the
value (increase its size), instead of moving the value
to the filesystem or re-shuffling the shared memory
cache, mmcache_put() returns 'true' even though it has
failed and not updated the value, because there is no
room to write the value back into memory.

What should happen is that the value is remove from
shared memory and added to the filesystem cache, or
'old' keys in the cache should be moved onto the
filesystem, to make room for the new value.

Some sort of memory rotation when the cache is full,
where old keys are pushed to the filesystem and when a
key is accessed it gets put cack into memory would be a
great idea.

I hope this makes sense and I have explained it well.

ps: the <mmcache@turckware.ru> address keeps bouncing.

Discussion