hunt-cache 0.8.2
A Powerfull Cache library for D. Support memory、redis、memcached backend.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
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
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
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?
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 ..
}
- Registered by zoujiaqing
- 0.8.2 released 2 months ago
- huntlabs/hunt-cache
- www.huntlabs.net
- Apache-2.0
- Copyright (C) 2015-2020, HuntLabs
- Dependencies:
- hunt-redis
- Versions:
-
0.8.2 2020-Nov-18 0.8.1 2020-Jun-09 0.8.0 2020-May-21 0.7.3 2020-Apr-29 0.6.6 2020-Apr-29 - Download Stats:
-
-
0 downloads today
-
2 downloads this week
-
28 downloads this month
-
1779 downloads total
-
- Score:
- 1.1
- Short URL:
- hunt-cache.dub.pm