hunt-cache ~master

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:

Build Status

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 ..
}

Dependencies:
hunt-redis
Versions:
0.10.1 2021-Nov-16
0.10.0 2021-Oct-29
0.9.1 2021-May-27
0.9.0 2021-Jan-27
0.8.3 2021-Nov-15
Show all 22 versions
Download Stats:
  • 0 downloads today

  • 1 downloads this week

  • 11 downloads this month

  • 3000 downloads total

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