Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huntlabs/hunt-cache
Cache library for D. Support memory、redis、memcached backend.
https://github.com/huntlabs/hunt-cache
cache memcache memcached memory redis
Last synced: about 1 month ago
JSON representation
Cache library for D. Support memory、redis、memcached backend.
- Host: GitHub
- URL: https://github.com/huntlabs/hunt-cache
- Owner: huntlabs
- Created: 2018-01-16T07:55:01.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T02:17:25.000Z (almost 2 years ago)
- Last Synced: 2024-09-28T08:42:14.066Z (about 1 month ago)
- Topics: cache, memcache, memcached, memory, redis
- Language: D
- Homepage: https://www.huntlabs.net
- Size: 2.41 MB
- Stars: 6
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-d - hunt-cache - D language universal cache library, using radix, redis and memcached. (Web Frameworks / Bare metal / kernel development)
README
[![Build Status](https://travis-ci.org/huntlabs/hunt-cache.svg?branch=master)](https://travis-ci.org/huntlabs/hunt-cache)
## Hunt Cache
Universal cache library for D programming language.## Support backend
* memory
* redis## Tips
Default support memory and redis drivers.## Sample code for Memory adapter
```D
import hunt.cache;import std.stdio;
void main()
{
auto cache = CacheFactory.create();// define key
string key = "my_cache_key";
// set cache
cache.set(key, "My cache value.");// get cache
string value = cache.get(key);writeln(value);
}
```## Sample code for struct & class
```D
import hunt.cache;import std.stdio;
struct User
{
string name;
int age;
}void main()
{
auto cache = CacheFactory.create();// define key
string key = "user_info";User user;
user.name = "zoujiaqing";
user.age = 99;// set cache
cache.set(key, user);// get cache
User userinfo = cache.get!User(key);writeln(userinfo.name);
}```
## How to use Redis adapter?
```D
import hunt.cache;import std.stdio;
void main()
{
CacheOption option;
option.adapter = "redis";
option.redis.host = "127.0.0.1";
option.redis.port = 6379;auto cache = CacheFactory.create(option);
// code for set / get ..
}```