本文整理汇总了Java中net.sf.jsr107cache.CacheFactory类的典型用法代码示例。如果您正苦于以下问题:Java CacheFactory类的具体用法?Java CacheFactory怎么用?Java CacheFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CacheFactory类属于net.sf.jsr107cache包,在下文中一共展示了CacheFactory类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: cache1
import net.sf.jsr107cache.CacheFactory; //导入依赖的package包/类
@Test
public void cache1 () {
Cache cache;
try {
CacheFactory cacheFactory = CacheManager.getInstance()
.getCacheFactory();
cache = cacheFactory.createCache(Collections.emptyMap());
}
catch (CacheException e) {
// ...
return;
};
cache.put("beispiel1", "Das ist ein Test");
cache.put("beispiel2", "Das ist ein Versuch");
cache.put("beispiel3", "Das ist ein Beispiel");
assertEquals(cache.get("beispiel1"), "Das ist ein Test");
assertEquals(cache.get("beispiel2"), "Das ist ein Versuch");
assertEquals(cache.get("beispiel3"), "Das ist ein Beispiel");
}
开发者ID:KorAP,项目名称:Krill,代码行数:25,代码来源:TestCache.java
示例2: addAndCheckSearchForIp
import net.sf.jsr107cache.CacheFactory; //导入依赖的package包/类
public int addAndCheckSearchForIp(String ip, int mode) {
String functionName = "addAndCheckSearchForIp()";
Cache cache;
Map<String, Integer> props = new HashMap<String, Integer>();
props.put(GCacheFactory.EXPIRATION_DELTA, 600); // 10 minutes
if(Utils.isUserInSpecialACL()) {
// System.err.println("No limit for user: " + Utils.getUser().getEmail() + "(" + Utils.getUser().getNickname() + ")");
Logger.getLogger(location).log(Level.INFO, functionName + ": No limit for user: " + Utils.getUser().getEmail() + "(" + Utils.getUser().getNickname() + ")");
return 1;
}
try {
String key = "requestCounter:" + mode + ":" + ip;
CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
cache = cacheFactory.createCache(props);
Integer counter = new Integer(1);
Integer o = (Integer)cache.get(key);
if(o != null) {
counter = counter + o;
}
cache.put(key, counter);
return counter;
} catch (CacheException e) {
Logger.getLogger(location).log(Level.SEVERE, functionName + ": caching error: " + e);
return -1;
}
}
开发者ID:Hellek1,项目名称:viaja-facil,代码行数:27,代码来源:Dao.java
示例3: doGet
import net.sf.jsr107cache.CacheFactory; //导入依赖的package包/类
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
CacheFactory cacheFactory;
try {
cacheFactory = CacheManager.getInstance().getCacheFactory();
Cache cache;
cache = cacheFactory.createCache(Collections.emptyMap());
cache.clear();
DataService.getInstance().saveConfig();
} catch (CacheException e) {
log.log(Level.SEVERE, "Error instantiating Cache");
}
log.log(Level.WARNING, "Cleared the Cache");
}
开发者ID:Rise-Vision,项目名称:rva,代码行数:17,代码来源:MemCacheClearServlet.java
示例4: init
import net.sf.jsr107cache.CacheFactory; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void init() {
log.log(Level.INFO, "REST servlet initialized");
try {
CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
cache = cacheFactory.createCache(Collections.emptyMap());
} catch (CacheException e) {
log.severe("Unable to initialize MemCache!");
}
this.userService = UserServiceFactory.getUserService();
this.persistence = new GaePersistence();
this.gson = new Gson();
repositoryPath2backupClass=new HashMap<String, Class>();
repositoryPath2backupClass.put("check-list-answers", BackupCheckListAnswerBean.class);
repositoryPath2backupClass.put("grows", BackupGrowBean.class);
repositoryPath2backupClass.put("grow-question-answers", BackupQuestionAnswerBean.class);
repositoryPath2backupClass.put("grow-questions", BackupQuestionBean.class);
repositoryPath2backupClass.put("users", BackupUserBean.class);
repositoryPath2backupClass.put("whitelist-entries", BackupWhitelistEntryBean.class);
repositoryPath2backupClass.put("life-visions", BackupLifeVisionBean.class);
repositoryPath2backupClass.put("friends", BackupFriendBean.class);
repositoryPath2backupClass.put("permissions", BackupPermissionBean.class);
repositoryPath2backupClass.put("question-comments", BackupQuestionBean.class);
repositoryPath2backupClass.put("user-settings", BackupUserSettingsBean.class);
repositoryPath2backupClass.put("note-attachments", BackupAttachmentBean.class);
}
开发者ID:dvorka,项目名称:coaching-notebook,代码行数:32,代码来源:RestServlet.java
示例5: MindForgerMemcache
import net.sf.jsr107cache.CacheFactory; //导入依赖的package包/类
public MindForgerMemcache() {
try {
// cluster > memcache (use of application cache makes no sense: cross cluster node, size, ...)
CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
memcache = cacheFactory.createCache(Collections.emptyMap());
} catch (CacheException e) {
LOG.severe("Unable to initialize MemCache!");
}
}
开发者ID:dvorka,项目名称:coaching-notebook,代码行数:10,代码来源:MindForgerMemcache.java
示例6: CacheHandler
import net.sf.jsr107cache.CacheFactory; //导入依赖的package包/类
private CacheHandler() {
try {
CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
cache = cacheFactory.createCache(Collections.emptyMap());
} catch (CacheException e) {
// Log stuff
log.log(Level.WARNING, "Error in creating the Cache");
}
}
开发者ID:Rise-Vision,项目名称:rva,代码行数:10,代码来源:CacheHandler.java
示例7: provideCache
import net.sf.jsr107cache.CacheFactory; //导入依赖的package包/类
@Provides
Cache provideCache() {
try {
CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
return cacheFactory.createCache(Collections.emptyMap());
} catch (CacheException e) {
// ...
}
return null;
}
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:11,代码来源:AppEngineModule.java
注:本文中的net.sf.jsr107cache.CacheFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论