Skip to content

Bejibun-Framework/bejibun-cache

Repository files navigation

Bejibun

GitHub top language NPM Downloads GitHub issues GitHub GitHub release (latest by date including pre-releases)

Cache for Bejibun

Cache for Bejibun Framework.

Usage

Installation

Install the package.

# Using Bun
bun add @bejibun/cache

# Using Bejibun
bun ace install @bejibun/cache

Configuration

The configuration file automatically executed if you are using ace.

Or

Add cache.ts inside config directory on your project if doesn't exist.

config/cache.ts
import App from "@bejibun/app";
import CacheDriverEnum from "@bejibun/utils/enums/CacheDriverEnum";

const config: Record<string, any> = {
    connection: "local",

    connections: {
        local: {
            driver: CacheDriverEnum.Local,
            path: App.Path.storagePath("cache") // absolute path
        },

        redis: {
            driver: CacheDriverEnum.Redis,
            host: "127.0.0.1",
            port: 6379,
            password: "",
            database: 0
        }
    }
};

export default config;

You can pass the value with environment variables.

How to Use

How to use tha package.

import Cache from "@bejibun/cache";

Cache.connection();
await Cache.remember("key", () => {}, 60 /* seconds */); // any
await Cache.has("key"); // boolean
await Cache.get("key"); // any
await Cache.add("key", "Hello world", 60 /* seconds */); // boolean
await Cache.put("key", "Lorem ipsum", 60 /* seconds */); // boolean
await Cache.forget("key"); // void
await Cache.increment("key"); // number
await Cache.decrement("key"); // number
await Cache.incrementBy("key", 5); // number
await Cache.decrementBy("key", 5); // number

Contributors

☕ Support / Donate

If you find this project helpful and want to support it, you can donate via crypto :

EVM Solana
0xdABe8750061410D35cE52EB2a418c8cB004788B3 GAnoyvy9p3QFyxikWDh9hA3fmSk2uiPLNWyQ579cckMn

Or you can buy this $BJBN (Bejibun) tokens here, beware of bots.

About

Cache for Bejibun Framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors