hunt-cache 0.6.0-rc.1

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:

Build Status

Hunt Cache

Universal cache library for D programming language.

Support backend

  • memory
  • redis
  • libmemcached

Versions

  • WITHHUNTCACHE
  • WITHHUNTREDIS
  • WITHHUNTMEMCACHE
  • WITHHUNTROCKSDB

Tips

Default support memory and redis drivers.

Sample code for Memory adapter

import hunt.cache;

import std.stdio;

void main()
{
    auto cache = CacheFectory.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 = CacheFectory.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 = CacheFectory.create(option);

    // code for set / get ..
}

Dependencies:
hunt-redis
Versions:
0.6.0-rc.1 2019-Jul-29
0.6.0-beta.2 2019-Jul-25
0.6.0-beta.1 2019-Jun-28
0.5.0 2019-Jun-04
0.4.1 2019-Mar-29
Show all 9 versions
Download Stats:
  • 0 downloads today

  • 6 downloads this week

  • 25 downloads this month

  • 759 downloads total

Score:
1.0
Short URL:
hunt-cache.dub.pm