English 中文(简体)
使用简单的弹出介面来取消命名空格
原标题:Invalidating namespace using simple spring memcached

Has anyone tried invalidating a memcached namespace based on timestamp? For e.g. I need to have a memcached namespace which is the timestamp of the tomcat server that hosts my API services. I need to annotate my method calls so that the namespace is a variable (rather than a constant) and it holds a timestamp of the server startup.

@ReadThroughAssignCache(namespace = "api_divisions_", assignedKey="allDivisions")
public List<Division> getAllDivisions()
{
    List<Division> all = (List<Division>)getHibernateTemplate().find("from Division");
    return all;
}

然后每次服务器启动时, 此方法上的命名空间需要动态设置为服务器启动时间 。

- 我知道最新消息,有 环绕的方式这样做 使用java助理 和动态说明, 但我想要一个更好的方法。

- Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz, Gotz

最佳回答

The namespace is always a constant, you cannot use variable. As I understand you want to create cache key using server startup time. There are at least two way how it can be done. First: use @ReadThroughSingleCache

@ReadThroughSingleCache(namespace = "api_divisions_allDivisions")
public List<Division> getAllDivisions(@ParameterValueKeyProvider long startup)
{
  List<Division> all = (List<Division>)getHibernateTemplate().find("from Division");
  return all;
}

第二:使用自定义 < a href=>" "https://sople-spring-memcached.googlecode.com/svn/docs/2.0.0/apidocs/com/google/code/ssm/aop/support/CacheKeyBuilder.html" rel="nofollow" >CacheKeyBuilder ,可以给每个缓存键添加时间戳。

您是否需要在服务器启动前存储旧的值? 如果不是, 简单的解决方案就是总是使用相同的缓存密钥, 并在服务器启动时清除杂交 。

问题回答

暂无回答




相关问题
Memcached Writes Extremely Slow

I m running memcached on ec2 instances and in some cases am seeing extremely slow writes (10s) for small amounts of data. I m using memcache-client from rails on the client side. Has anyone seen ...

can t install memcache php module

i m trying to install memcache module from http://pecl.php.net/package/memcache. Im using xampp in ubuntu (lampp) with php 5.3. After download the extension, I run phpize, make and make install, then ...

sphinx is returning stale results

Environment: Memcached, Rails 2.2.2 + cache_money, Sphinx + thinking sphinx The following yields stale results: - add a record; mysql contains the correct data - the record is probably cached in ...

Pylons and Memcached

Anyone happen to use this combination in their web application? I m having a bit of trouble finding some sort of tutorial or guideline for configuring this. Also seeing as how I started using Pylons ...

Memcached crashing under moderate load

When running memcached, after a few minutes of use it starts throwing the following errors and memcache stops responding. mcm_server_connect_next_avail():2328 I have searched the Google, and it ...

enyim and memcached : NOT_STORED errors

We are using memcached 1.2.4 via enyim and are finding it difficult to get some objects to cache. If I watch the memcache console it just says NOT_STORED . I think we need to use [serializable] but ...

PHP - Memcache - HTML Caching

I would like to create a caching system that will bypass some mechanisms in order to improve the performance. I have some examples: 1-) I have a dynamic PHP page that is updated every hour. The page ...

热门标签