gitea: code.gitea.io/gitea/modules/cache Index | Files

package cache

import "code.gitea.io/gitea/modules/cache"

Index

Package Files

cache.go cache_redis.go

func GetInt Uses

func GetInt(key string, getFunc func() (int, error)) (int, error)

GetInt returns key value from cache with callback when no key exists in cache

func GetInt64 Uses

func GetInt64(key string, getFunc func() (int64, error)) (int64, error)

GetInt64 returns key value from cache with callback when no key exists in cache

func GetString Uses

func GetString(key string, getFunc func() (string, error)) (string, error)

GetString returns the key value from cache with callback when no key exists in cache

func NewContext Uses

func NewContext() error

NewContext start cache service

func Remove Uses

func Remove(key string)

Remove key from cache

type Cache Uses

type Cache interface {
    // Put puts value into cache with key and expire time.
    Put(key string, val interface{}, timeout int64) error
    // Get gets cached value by given key.
    Get(key string) interface{}
    // Delete deletes cached value by given key.
    Delete(key string) error
    // Incr increases cached int-type value by given key as a counter.
    Incr(key string) error
    // Decr decreases cached int-type value by given key as a counter.
    Decr(key string) error
    // IsExist returns true if cached value exists.
    IsExist(key string) bool
    // Flush deletes all cached data.
    Flush() error
}

Cache is the interface that operates the cache data.

func GetCache Uses

func GetCache() Cache

GetCache returns the currently configured cache

type RedisCacher Uses

type RedisCacher struct {
    // contains filtered or unexported fields
}

RedisCacher represents a redis cache adapter implementation.

func (*RedisCacher) Decr Uses

func (c *RedisCacher) Decr(key string) error

Decr decreases cached int-type value by given key as a counter.

func (*RedisCacher) Delete Uses

func (c *RedisCacher) Delete(key string) error

Delete deletes cached value by given key.

func (*RedisCacher) Flush Uses

func (c *RedisCacher) Flush() error

Flush deletes all cached data.

func (*RedisCacher) Get Uses

func (c *RedisCacher) Get(key string) interface{}

Get gets cached value by given key.

func (*RedisCacher) Incr Uses

func (c *RedisCacher) Incr(key string) error

Incr increases cached int-type value by given key as a counter.

func (*RedisCacher) IsExist Uses

func (c *RedisCacher) IsExist(key string) bool

IsExist returns true if cached value exists.

func (*RedisCacher) Put Uses

func (c *RedisCacher) Put(key string, val interface{}, expire int64) error

Put puts value into cache with key and expire time. If expired is 0, it lives forever.

func (*RedisCacher) StartAndGC Uses

func (c *RedisCacher) StartAndGC(opts cache.Options) error

StartAndGC starts GC routine based on config string settings. AdapterConfig: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180,hset_name=MacaronCache,prefix=cache:

Package cache imports 9 packages (graph) and is imported by 54 packages. Updated 2021-01-22. Refresh now. Tools for package owners.