Giter VIP home page Giter VIP logo

spymemcached-jcache's Introduction

spymemcached-jcache

spymemcached-jcache is a JSR107 JCache provider using spymemcached as memcache client.

Features

  • namespace support by cache name, cache name should be \w+
  • add seperator support, default is $. You can set the seperator in the url, such as memcached://localhost:11211?seperator=$$
  • expose native cache api by unwrap
  • CacheLoader support to auto load data from backend

Usage

First we should find the caching provider, then create cache manager from the provider, finally we create the cache to operate cache entries.

   SpyCachingProvider provider = new SpyCachingProvider();
   CacheManager cacheManager = provider.getCacheManager(URI.create("memcached://localhost:11211"), null);
   Cache<Integer, Object> cache = cacheManager.getCache("user");
   cache.put(1, "linux_china");
   System.out.println(cache.get(1));
   MemcachedClient memcacheClient = cache.unwrap(MemcachedClient.class);
   Object object = memcacheClient.get("user$1");
   System.out.println(object);

FAQ

set custom seperator

You can set the seperator in the url, such as memcached://localhost:11211?seperator=$$

cache:memcached:localhost:11211?sperator=$$ cache:memcached:localhost:11211,localhost:11212?sperator=$$

add multi memcached hosts

Please add peer param in the url, such as memcached://localhost:11211?peer=localhost:11212;localhost:11213 Hosts splitted by ";".

Convert Cache to Map

  Map<String, Object> store = cache.unwrap(Map.class);

How to get MemcachedClient object to execute some commands?

Two way:

    MemcachedClient memcacheClient = cacheManager.unwrap(MemcachedClient.class);

or

    MemcachedClient memcacheClient = cache.unwrap(MemcachedClient.class);

Todo

  • Implement all JSR 107 features
  • Concurrency
  • event, event filter
  • management, statics
  • ๅ‚่€ƒ [email protected]:ehcache/ehcache-jcache.git

Cache class diagram

  • Cache Provider
  • Cache Manager
  • Cache
  • Entry
  • Key
  • Value

As a cache provider, you should ext CacheProvider, CacheManager, Cache, CacheEntry and Cache value.

JCache specification

  • compute: processor package, such as javax.cache.Cache.invoke and javax.cache.Cache.invokeAll

Question

  • transaction support for getAndRemove etc

spymemcached-jcache's People

Contributors

linux-china avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

mniebla smalltao

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.