MCPcopy Index your code
hub / github.com/adelowo/onecache

github.com/adelowo/onecache @2.6.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.6.2 ↗ · + Follow
130 symbols 402 edges 15 files 28 documented · 22%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

OneCache - A Go caching Library

Coverage Status Build Status

Installation


$ go get -u github.com/adelowo/onecache

Supported cache stores

  • [x] InMemory
  • [x] Filesystem
  • [x] Memcached
  • [x] Redis

OneCache also comes with garbage collection. This is used by the filesystem and memory adapter to purge out expired items automatically. Please refer to the examples

Examples containing all adapters can be found here

var store onecache.Store

store = filesystem.MustNewFSStore("/home/adez/onecache_tmp")

err := store.Set("profile", []byte("Lanre"), time.Second*60)

if err != nil {
    fmt.Println(err)
    return
}

value,err := store.Get("profile")
if err != nil {
    fmt.Println(err)
    return
}

fmt.Println(string(value))

Some adapters like the filesystem and memory have a Garbage collection implementation. All that is needed to call is store.GC(). Ideally, this should be called in a ticker.C.

LICENSE

MIT

Extension points exported contracts — how you extend this code

Store (Interface)
Interface for all onecache store implementations [4 implementers]
types.go
Serializer (Interface)
(no doc) [2 implementers]
utils.go
Option (FuncType)
Option defines options for creating a memory store
memory/option.go
Option (FuncType)
Option defines a Memcached option
memcached/memcached.go
Option (FuncType)
Option is an optional type
filesystem/option.go
Option (FuncType)
Option is a redis option type
redis/redis.go
GarbageCollector (Interface)
Some stores like redis and memcache automatically clear out the cache But for the filesystem and in memory, this cannot [2 …
types.go
KeyFunc (FuncType)
KeyFunc defines a transformer for cache keys
types.go

Core symbols most depended-on inside this repo

Set
called by 23
types.go
Get
called by 20
types.go
Flush
called by 8
types.go
MustNewFSStore
called by 8
filesystem/fs.go
Delete
called by 6
types.go
Has
called by 6
types.go
filePathFor
called by 6
filesystem/fs.go
IsExpired
called by 5
utils.go

Shape

Function 74
Method 40
Struct 8
FuncType 5
Interface 3

Languages

Go100%

Modules by API surface

filesystem/fs_test.go17 symbols
filesystem/fs.go13 symbols
redis/redis.go12 symbols
memcached/memcached.go12 symbols
types.go11 symbols
memory/memory.go11 symbols
utils.go10 symbols
memory/memory_test.go10 symbols
redis/redis_test.go7 symbols
memcached/memcached_test.go7 symbols
utils_test.go6 symbols
_examples/main.go6 symbols

For agents

$ claude mcp add onecache \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact