https://github.com/mohanarpit/cache-wrapper
This is an extremely simple wrapper around different caching back-ends.
https://github.com/mohanarpit/cache-wrapper
Last synced: over 1 year ago
JSON representation
This is an extremely simple wrapper around different caching back-ends.
- Host: GitHub
- URL: https://github.com/mohanarpit/cache-wrapper
- Owner: mohanarpit
- Created: 2014-07-31T19:33:47.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-07-31T21:19:50.000Z (almost 12 years ago)
- Last Synced: 2025-02-10T00:44:52.670Z (over 1 year ago)
- Language: Java
- Size: 207 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
CacheWrapper
============
This is an extremely simple wrapper around different caching back-ends.
Current back-ends supported:
* Memcache
* Redis (minimal support for Redis as an LRU cache. Clustering not enabled for Redis)
Add this repository as an alternate repository
```xml
cache-wrapper-mvn-repo
https://raw.github.com/mohanarpit/cache-wrapper/mvn-repo/
true
always
```
Add the dependency to your pom.xml as below
```xml
com.arpit
cache-wrapper
0.0.1-SNAPSHOT
```
### Sample Usage:
Set the configs such as host, number of connections etc.
```java
Config config = new Config();
config.setNodes("localhost");
Cache cache = new Cache();
cache.setConfig(config);
```
Get the instance of the cache that you want.
For Memcache
```java
CacheInterface cmem = cache.getInstance("memcache");
```
For Redis
```java
CacheInterface cred = cache.getInstance("redis");
```
Simply use it as a cache now
```java
cmem.set("key", 0, "values");
System.out.println(cmem.get("key"));
cred.set("key", 0, "values");
System.out.println(cred.get("key"));
```
That's it! Dance around in glorious joy :)