Options
All
  • Public
  • Public/Protected
  • All
Menu

Module cache

Index

Variables

Const lockDuration

lockDuration: any = config.general.lockDuration

Let lockNameOverride

lockNameOverride: any

Const lockPrefix

lockPrefix: any = config.general.lockPrefix

Const lockRetry

lockRetry: 100 = 100

Const redisPrefix

redisPrefix: any = config.general.cachePrefix

Functions

checkLock

  • checkLock(key: string, retry?: boolean | number, startTime?: number): any
  • Parameters

    • key: string
    • Default value retry: boolean | number = false
    • Default value startTime: number = new Date().getTime()

    Returns any

clear

  • clear(): Promise<boolean>
  • Removes all keys in redis which are under this ActionHero namespace. Potentially very slow.

    Returns Promise<boolean>

client

  • client(): Redis

destroy

  • destroy(key: string): Promise<boolean>
  • Delete an item in the cache. Will throw an error if the item named by key is locked. Automatically handels api.cache.redisPrefix

    Parameters

    • key: string

    Returns Promise<boolean>

dumpRead

  • dumpRead(file: string): Promise<number>
  • Load in contents for redis (and api.cache) saved to a file Warning! Any existing keys in redis (under this ActionHero namespace) will be removed.

    Parameters

    • file: string

    Returns Promise<number>

dumpWrite

  • dumpWrite(file: string): Promise<number>
  • Write the current concents of redis (only the keys in ActionHero's namespace) to a file.

    Parameters

    • file: string

    Returns Promise<number>

keys

  • keys(): Promise<Array<string>>
  • Returns all the keys in redis which are under this ActionHero namespace. Potentially very slow.

    Returns Promise<Array<string>>

listLength

  • listLength(key: string): Promise<number>
  • Check how many items are stored in a shared queue/list in redis.

    Parameters

    • key: string

    Returns Promise<number>

load

  • Load an item from the cache. Will throw an error if the item named by key cannot be found. Automatically handels api.cache.redisPrefix

    Parameters

    Returns Promise<CacheObject>

lock

  • lock(key: string, expireTimeMS?: number): Promise<boolean>
  • Lock an item in redis (can be a list or a saved item) to this ActionHero process.

    Parameters

    • key: string
    • Default value expireTimeMS: number = lockDuration

    Returns Promise<boolean>

lockName

  • lockName(): any

locks

  • locks(): Promise<Array<string>>
  • Returns all the locks in redis which are under this ActionHero namespace. Potentially slow.

    Returns Promise<Array<string>>

overrideLockName

  • overrideLockName(name: string): void

pop

  • pop(key: string): Promise<boolean>
  • Pop (get) an item to a shared queue/list in redis. Automatically handels api.cache.redisPrefix

    Parameters

    • key: string

    Returns Promise<boolean>

push

  • push(key: string, item: any): Promise<boolean>
  • Push an item to a shared queue/list in redis. Automatically handels api.cache.redisPrefix

    Parameters

    • key: string
    • item: any

    Returns Promise<boolean>

save

  • save(key: string, value: any, expireTimeMS?: number): Promise<boolean>
  • Save an item in the cache. If an item is already in the cache with the same key, it will be overritten. Throws an error if the object is already in the cache and is locked. Automatically handels api.cache.redisPrefix

    Parameters

    • key: string
    • value: any
    • Optional expireTimeMS: number

    Returns Promise<boolean>

size

  • size(): Promise<number>
  • Returns the number of keys in redis which are under this ActionHero namespace. Potentially very slow.

    Returns Promise<number>

unlock

  • unlock(key: string): Promise<boolean>
  • Unlock an item in redis (can be a list or a saved item) which was previously locked by this ActionHero process.

    Parameters

    • key: string

    Returns Promise<boolean>

Generated using TypeDoc