Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PresenceCache

Cache responsible for storing presence related data

Hierarchy

Index

Methods

addToIndex

  • addToIndex(id: string, objectId?: string): Promise<void>
  • Add ids to the index of a namespace

    Parameters

    • id: string

      ids to add

    • objectId: string = ...

      id of the parent object of the index

    Returns Promise<void>

bindGuild

  • Bind a guild id to the cache

    Parameters

    • guildId: string

      id of the guild that should be bound to this cache

    Returns PresenceCache

bindObject

  • bindObject(boundObject: Partial<PresenceData>): void
  • Bind an object to the cache instance, you can read more on binding on the landing page of the documentation

    Parameters

    • boundObject: Partial<PresenceData>

      Object to bind to this cache instance

    Returns void

buildId

  • buildId(id: string): string
  • Build an id consisting of $namespace.$id

    Parameters

    • id: string

      id to append to namespace

    Returns string

    constructed id

get

getIndexCount

  • getIndexCount(objectId?: string): Promise<number>
  • Get the number of elements that are within an index

    Parameters

    • objectId: string = ...

      id of the parent object of the index

    Returns Promise<number>

getIndexMembers

  • getIndexMembers(objectId?: string): Promise<string[]>
  • Get all members from an index

    Parameters

    • objectId: string = ...

      id of the parent object of the index

    Returns Promise<string[]>

isIndexed

  • isIndexed(id: string, objectId?: string): Promise<boolean>
  • Check if an id is a member of an index

    Parameters

    • id: string

      id to check

    • objectId: string = ...

      id of the parent object of the index

    Returns Promise<boolean>

    returns true if it is a part of the index, false otherwise

remove

removeFromIndex

  • removeFromIndex(id: string, objectId?: string): Promise<void>
  • Remove an id from the index

    Parameters

    • id: string

      id to be removed

    • objectId: string = ...

      id of the parent object of the index

    Returns Promise<void>

removeIndex

  • removeIndex(objectId?: string): Promise<void>
  • Delete an index

    Parameters

    • objectId: string = ...

      id of the parent object of the index

    Returns Promise<void>

structurize

  • structurize<D>(data: Partial<D>): Partial<D>
  • Delete keys from data if necessary based on RainCache structureDefs options and return the cleaned data

    Type parameters

    • D

    Parameters

    • data: Partial<D>

      The data to possibly delete object entries from

    Returns Partial<D>

update

  • Upsert the presence of a user.

    This function automatically removes the guild_id, roles and user of a presence update before saving it

    Parameters

    • id: string

      id of the user the presence belongs to

    • data: Partial<PresenceData>

      updated presence data of the user

    Returns Promise<PresenceCache>

    returns a bound presence cache

Properties

Optional boundGuild

boundGuild?: string

guild id bound to this cache

boundObject

boundObject: null | Partial<PresenceData> = null

dataTimestamp

dataTimestamp: null | Date = null

namespace

namespace: "presence" = "presence"

rain

rain: RainCache<any, any>

storageEngine

storageEngine: BaseStorageEngine<PresenceData>

userCache

userCache: UserCache

Constructors

constructor

  • Create a new Presence Cache

    This class is automatically instantiated by RainCache

    Parameters

    • storageEngine: BaseStorageEngine<PresenceData>

      Storage engine to use for this cache

    • userCache: UserCache
    • rain: RainCache<any, any>
    • Optional boundObject: Partial<PresenceData>

      Optional, may be used to bind a presence object to the cache

    Returns PresenceCache

Generated using TypeDoc