The Problem
It seem as thought no matter what values we configure memcached to use as an expiration time all of the items in the cache get an expiration time of 5 minutes.
What We Have Tried
- Using an expiration of 0, all documentation indicates that this means the items should never expire.
- Using an expiration of 600 seconds.
- Using a Unix time stamp several hours in the future (eg. 1455058122).
In all cases when an item is cached and I retrieve the cachedump the expiration timestamp is only 5 minutes in the future.
This has been very frustrating as memcached works awesome except for this major flaw.
The Setup
- .NET 3.5
- Visual Studio 2015
- NHibernate 3.1.0.4000
- EnyimCached 2.3.0.0
- Memcached 1.4.5_4_gaa7839e
Web.config
<enyimmemcache>
<memcached protocol="Binary">
<servers>
<add key="MemcachedAddress" address="127.0.0.1" port="11211" />
<!-- Add new servers here -->
</servers>
<socketPool connectionTimeout="00:00:02" />
<cache region="system" expiration="0" priority="5" />
</memcached>
</enyimmemcache>
Hibernate Config
<property name="cache.provider_class">NHibernate.Caches.EnyimMemcached.MemCacheProvider,NHibernate.Caches.EnyimMemcached</property>
<property name="cache.use_second_level_cache">true</property>
Stats.bat
@echo off>nul
setlocal EnableDelayedExpansion
IF "%1"=="-o" rm dump.log
set SAVESTAMP=%DATE:/=-%@%TIME::=:%
echo --------------[%SAVESTAMP%]-------------- >> dump.log
echo stats items | nc 127.0.0.1 11211 > statsitems
SET myvar=""
FOR /f "tokens=1,2,3 delims=:" %%i in (statsitems) do (
if NOT %%j==!myvar! (
SET myvar=%%j
echo stats cachedump !myvar! 1000000 | nc 127.0.0.1 11211 >> dump.log
)
)
rm statsitems