C C PHP Java Python Ruby Perl NET
Использование � Реализации клиентских библиотек для многих языков программирования (C / C++, PHP, Java, Python, Ruby, Perl, . NET, My. SQL, Postgre. SQL, Erlang, Lua, и др. ) � Используется в: You. Tube Live. Journal, Wikipedia/Wikimedia, Amazon. com, Wikia, Source. Forge, Metacafe, Facebook, Twitter, Fotolog, The Pirate Bay etc.
Библиотека spymemcached � Memcached. Client � � // c=new Memcached. Client( new Inet. Socket. Address("hostname", port. Num)); Store a value (async) for one hour � c. set("some. Key", 3600, some. Object); � // Retrieve a value (synchronously). � Object my. Object=c. get("some. Key");
Библиотека spymemcached // Get a memcached client connected to several servers � Memcached. Client c=new Memcached. Client( � Addr. Util. get. Addresses("server 1: 11211 server 2: 11211")); � // Try to get a value, for up to 5 seconds, and cancel if it doesn't return � Object my. Obj=null; � Future<Object> f=c. async. Get("some. Key"); � try { � my. Obj=f. get(5, Time. Unit. SECONDS); � } catch(Timeout. Exception e) { � // Since we don't need this, go ahead and cancel the operation. This � // is not strictly necessary, but it'll save some work on the server. � f. cancel(false); � // Do other timeout related stuff �} �
Библиотека spymemcached � get � public Object get(String key)Get with a single key and decode using the default transcoder. � Specified by: get in interface Memcached. Client. IFParameters: key - the key to get. Returns: the result from the cache (null if there is none)Throws: Operation. Timeout. Exception if the global operation timeout is exceeded. Illegal. State. Exception - in the rare circumstance where queue is too full to accept any more requests
Библиотека spymemcached � async. Get � public Future<Object> async. Get(String key)Get the given key asynchronously and decode with the default transcoder. � Specified by: async. Get in interface Memcached. Client. IFParameters: key - the key to fetch. Returns: a future that will hold the return value of the fetch. Throws: Illegal. State. Exception - in the rare circumstance where queue is too full to accept any more requests
- Slides: 13