net.rubyeye.xmemcached.exception.MemcachedException Java Examples
The following examples show how to use
net.rubyeye.xmemcached.exception.MemcachedException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MemcacheServlet.java From java-docs-samples with Apache License 2.0 | 6 votes |
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { String addr = System.getenv().containsKey("GAE_MEMCACHE_HOST") ? System.getenv("GAE_MEMCACHE_HOST") : "localhost"; String port = System.getenv().containsKey("GAE_MEMCACHE_HOST") ? System.getenv("GAE_MEMCACHE_PORT") : "11211"; String key = "count"; MemcachedClientBuilder builder = new XMemcachedClientBuilder( AddrUtil.getAddresses(addr + ":" + port)); MemcachedClient client = builder.build(); long count = 0L; try { count = client.incr(key, 1L, 0L); } catch (TimeoutException | InterruptedException | MemcachedException e) { throw new ServletException("Memcache error", e); } resp.setContentType("text/plain"); resp.getWriter().print("Value is " + count + "\n"); }
Example #2
Source File: TestFqueueServer.java From fqueue with Apache License 2.0 | 6 votes |
public void mutiThreadGet() throws InterruptedException, TimeoutException, MemcachedException { int threadCount = 8; ExecutorService pool = Executors.newFixedThreadPool(threadCount); CountDownLatch latch = new CountDownLatch(threadCount); // MemcachedBenchJob.test = tester; MemcachedTestGet[] muti = new MemcachedTestGet[threadCount]; for (int i = 0; i < threadCount; i++) { muti[i] = new MemcachedTestGet(latch); } log.info("start"); long start = System.currentTimeMillis(); for (int i = 0; i < threadCount; i++) { pool.execute(muti[i]); } latch.await(); long spend = System.currentTimeMillis() - start; log.info(threadCount + "threads 获取次数:" + threadCount * 10000); assertEquals(0, getSize()); }
Example #3
Source File: TestFqueueServer.java From fqueue with Apache License 2.0 | 6 votes |
public void mutiThreadWrite() throws InterruptedException, TimeoutException, MemcachedException { int threadCount = 8; ExecutorService pool = Executors.newFixedThreadPool(threadCount); CountDownLatch latch = new CountDownLatch(threadCount); // MemcachedBenchJob.test = tester; MemcachedTest[] muti = new MemcachedTest[threadCount]; for (int i = 0; i < threadCount; i++) { muti[i] = new MemcachedTest(latch); } log.info("start"); long start = System.currentTimeMillis(); for (int i = 0; i < threadCount; i++) { pool.execute(muti[i]); } latch.await(); long spend = System.currentTimeMillis() - start; log.info(threadCount + "threads写入次数:" + threadCount * 10000 + " spend:" + spend + " ms"); assertEquals(threadCount * 10000, getSize()); }
Example #4
Source File: TestFqueueServer.java From fqueue with Apache License 2.0 | 6 votes |
public void mutiThreadGet() throws InterruptedException, TimeoutException, MemcachedException { int threadCount = 8; ExecutorService pool = Executors.newFixedThreadPool(threadCount); CountDownLatch latch = new CountDownLatch(threadCount); // MemcachedBenchJob.test = tester; MemcachedTestGet[] muti = new MemcachedTestGet[threadCount]; for (int i = 0; i < threadCount; i++) { muti[i] = new MemcachedTestGet(latch); } log.info("start"); long start = System.currentTimeMillis(); for (int i = 0; i < threadCount; i++) { pool.execute(muti[i]); } latch.await(); long spend = System.currentTimeMillis() - start; log.info(threadCount + "threads 获取次数:" + threadCount * 10000); assertEquals(0, getSize()); }
Example #5
Source File: TestFqueueServer.java From fqueue with Apache License 2.0 | 6 votes |
public void mutiThreadWrite() throws InterruptedException, TimeoutException, MemcachedException { int threadCount = 8; ExecutorService pool = Executors.newFixedThreadPool(threadCount); CountDownLatch latch = new CountDownLatch(threadCount); // MemcachedBenchJob.test = tester; MemcachedTest[] muti = new MemcachedTest[threadCount]; for (int i = 0; i < threadCount; i++) { muti[i] = new MemcachedTest(latch); } log.info("start"); long start = System.currentTimeMillis(); for (int i = 0; i < threadCount; i++) { pool.execute(muti[i]); } latch.await(); long spend = System.currentTimeMillis() - start; log.info(threadCount + "threads写入次数:" + threadCount * 10000 + " spend:" + spend + " ms"); assertEquals(threadCount * 10000, getSize()); }
Example #6
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public boolean set(final String key, final int exp, final Object value) throws TimeoutException, CacheException { try { return memcachedClient.set(key, exp, value); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #7
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public long incr(final String key, final int by) throws TimeoutException, CacheException { try { return memcachedClient.incr(key, by); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #8
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public <T> boolean set(final String key, final int exp, final T value, final CacheTranscoder transcoder) throws TimeoutException, CacheException { try { return memcachedClient.set(key, exp, value, getTranscoder(transcoder)); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #9
Source File: MemcacheClientWrapperTest.java From simple-spring-memcached with MIT License | 5 votes |
@Test public void setStringIntObject() throws TimeoutException, InterruptedException, MemcachedException, CacheException { EasyMock.expect(client.set("key1", 1, "value")).andReturn(true); EasyMock.replay(client); assertTrue(clientWrapper.set("key1", 1, "value")); EasyMock.verify(client); }
Example #10
Source File: MemcacheClientWrapperTest.java From simple-spring-memcached with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void getBulkCollectionOfStringMemcacheTranscoderOfT() throws TimeoutException, InterruptedException, MemcachedException, CacheException { Collection<String> keys = EasyMock.createMock(Collection.class); Map<String, Object> results = EasyMock.createMock(Map.class); CacheTranscoder transcoder = EasyMock.createMock(CacheTranscoder.class); EasyMock.expect(client.get(EasyMock.eq(keys), EasyMock.anyObject(Transcoder.class))).andReturn(results); EasyMock.replay(client); assertEquals(results, clientWrapper.getBulk(keys, transcoder)); EasyMock.verify(client); }
Example #11
Source File: MemcacheClientWrapperTest.java From simple-spring-memcached with MIT License | 5 votes |
@Test public void incrStringInt() throws TimeoutException, InterruptedException, MemcachedException, CacheException { EasyMock.expect(client.incr("key1", 1)).andReturn(2L); EasyMock.replay(client); assertEquals(2L, clientWrapper.incr("key1", 1)); EasyMock.verify(client); }
Example #12
Source File: MemcacheClientWrapperTest.java From simple-spring-memcached with MIT License | 5 votes |
@Test public void incrStringIntLong() throws TimeoutException, InterruptedException, MemcachedException, CacheException { EasyMock.expect(client.incr("key1", 1, 10L)).andReturn(2L); EasyMock.replay(client); assertEquals(2L, clientWrapper.incr("key1", 1, 10)); EasyMock.verify(client); }
Example #13
Source File: MemcacheClientWrapperTest.java From simple-spring-memcached with MIT License | 5 votes |
@Test public void incrStringIntLongInt() throws TimeoutException, InterruptedException, MemcachedException, CacheException { EasyMock.expect(client.getOpTimeout()).andReturn(100L); EasyMock.expect(client.incr("key1", 1, 10L, 100L, 1000)).andReturn(2L); EasyMock.replay(client); assertEquals(2L, clientWrapper.incr("key1", 1, 10L, 1000)); EasyMock.verify(client); }
Example #14
Source File: XmemcachedSessionDataStorage.java From pippo with Apache License 2.0 | 5 votes |
@Override public void save(SessionData sessionData) { try { this.sessions.set(sessionData.getId(), idleTime, sessionData); } catch (TimeoutException | InterruptedException | MemcachedException ex) { log.error("An error occurred when saved SessionData.", ex); } }
Example #15
Source File: AuthenticationInfoUtil.java From ChengFeng1.5 with MIT License | 5 votes |
public static com.beautifulsoup.chengfeng.pojo.User getUser(UserMapper userMapper, MemcachedClient memcachedClient) throws InterruptedException, MemcachedException, TimeoutException { User authenticationInfo = AuthenticationInfoUtil.getAuthenticationInfo(); String userJson = memcachedClient.get(authenticationInfo.getUsername()); com.beautifulsoup.chengfeng.pojo.User user; if (!StringUtils.isBlank(userJson)){ user= JsonSerializableUtil.string2Obj(userJson, com.beautifulsoup.chengfeng.pojo.User.class); }else{ user=userMapper.selectByNickname(authenticationInfo.getUsername()); } return user; }
Example #16
Source File: XmemcachedSessionDataStorage.java From pippo with Apache License 2.0 | 5 votes |
@Override public SessionData get(String sessionId) { try { return this.sessions.get(sessionId); } catch (TimeoutException | InterruptedException | MemcachedException ex) { log.error("An error occurred when get SessionData.", ex); return null; } }
Example #17
Source File: MemcacheClientWrapperTest.java From simple-spring-memcached with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void getBulkCollectionOfString() throws TimeoutException, InterruptedException, MemcachedException, CacheException { Collection<String> keys = EasyMock.createMock(Collection.class); Map<String, Object> results = EasyMock.createMock(Map.class); EasyMock.expect(client.get(keys)).andReturn(results); EasyMock.replay(client); assertEquals(results, clientWrapper.getBulk(keys)); EasyMock.verify(client); }
Example #18
Source File: MemcacheClientWrapperTest.java From simple-spring-memcached with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void setStringIntTMemcacheTranscoderOfT() throws TimeoutException, InterruptedException, MemcachedException, CacheException { CacheTranscoder transcoder = EasyMock.createMock(CacheTranscoder.class); EasyMock.expect(client.set(EasyMock.eq("key1"), EasyMock.eq(1), EasyMock.eq("value"), EasyMock.anyObject(Transcoder.class))) .andReturn(true); EasyMock.replay(client); assertTrue(clientWrapper.set("key1", 1, "value", transcoder)); EasyMock.verify(client); }
Example #19
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public long incr(final String key, final int by, final long def, final int expiration) throws TimeoutException, CacheException { try { return memcachedClient.incr(key, by, def, memcachedClient.getOpTimeout(), expiration); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #20
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public long incr(final String key, final int by, final long def) throws TimeoutException, CacheException { try { return memcachedClient.incr(key, by, def); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #21
Source File: MemcacheClientWrapperTest.java From simple-spring-memcached with MIT License | 5 votes |
@Test public void addStringIntObject() throws TimeoutException, InterruptedException, MemcachedException, CacheException { EasyMock.expect(client.add("test", 1000, "value")).andReturn(true); EasyMock.replay(client); assertTrue(clientWrapper.add("test", 1000, "value")); EasyMock.verify(client); }
Example #22
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public <T> Map<String, T> getBulk(final Collection<String> keys, final CacheTranscoder transcoder) throws TimeoutException, CacheException { Map<String, T> result = null; try { result = memcachedClient.get(keys, this.<T> getTranscoder(transcoder)); return (result == null) ? Collections.<String, T> emptyMap() : result; } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #23
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public Map<String, Object> getBulk(final Collection<String> keys) throws TimeoutException, CacheException { Map<String, Object> result = null; try { result = memcachedClient.get(keys); return (result == null) ? Collections.<String, Object> emptyMap() : result; } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #24
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public <T> T get(final String key, final CacheTranscoder transcoder, final long timeout) throws TimeoutException, CacheException { try { return memcachedClient.get(key, timeout, this.<T> getTranscoder(transcoder)); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #25
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public <T> T get(final String key, final CacheTranscoder transcoder) throws TimeoutException, CacheException { try { return memcachedClient.get(key, this.<T> getTranscoder(transcoder)); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #26
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public Object get(final String key) throws TimeoutException, CacheException { try { return memcachedClient.get(key); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #27
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public void flush() throws TimeoutException, CacheException { try { memcachedClient.flushAll(); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #28
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public boolean delete(final String key) throws TimeoutException, CacheException { try { return memcachedClient.delete(key); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #29
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public long decr(final String key, final int by, final long def) throws TimeoutException, CacheException { try { return memcachedClient.decr(key, by, def); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }
Example #30
Source File: MemcacheClientWrapper.java From simple-spring-memcached with MIT License | 5 votes |
@Override public long decr(final String key, final int by) throws TimeoutException, CacheException { try { return memcachedClient.decr(key, by); } catch (MemcachedException | InterruptedException e) { throw new CacheException(e); } }