# Class CacheInstance

Base class for all SDK objects.

This class provides a base implementation for all SDK objects. It handles event emission, promise management, and initialization.

This object is used to ensure that an SRE instance is initialized, and if not, create one with default settings.

#### Hierarchy (View Summary)

- SDKObject
  - CacheInstance

- Defined in src/Cache/CacheInstance.class.ts:6

##### Index

### Constructors

constructor

### Properties

_readyPromise

### Accessors

ready

### Methods

delete
emit
exists
get
getTTL
init
initSignal
off
on
once
removeListener
set
updateTTL

## Constructors

### constructor

- new CacheInstance(
  providerId?: TCacheProvider,
  cacheSettings?: any,
  candidate?: AccessCandidate,
  ): CacheInstance

  #### Parameters

  - `Optional` providerId: TCacheProvider
  - cacheSettings: any = {}
  - `Optional` candidate: AccessCandidate

  #### Returns CacheInstance

  Overrides SDKObject.constructor

  - Defined in src/Cache/CacheInstance.class.ts:10

## Properties

### `Protected`_readyPromise

_readyPromise: ControlledPromise<any>

Inherited from SDKObject._readyPromise

- Defined in src/Core/SDKObject.class.ts:17

## Accessors

### ready

- get ready(): ControlledPromise<any>

  #### Returns ControlledPromise<any>

  Inherited from SDKObject.ready

  - Defined in src/Core/SDKObject.class.ts:19

## Methods

### delete

- delete(key: string): Promise<void>

  Delete a value from the cache

  #### Parameters

  - key: string

    The key to delete

  #### Returns Promise<void>

  - Defined in src/Cache/CacheInstance.class.ts:56

### emit

- emit(event: string, ...args: any[]): void

  #### Parameters

  - event: string
  - ...args: any[]

  #### Returns void

  Inherited from SDKObject.emit

  - Defined in src/Core/SDKObject.class.ts:45

### exists

- exists(key: string): Promise<boolean>

  Check if a key exists in the cache

  #### Parameters

  - key: string

    The key to check

  #### Returns Promise<boolean>

  true if the key exists

  - Defined in src/Cache/CacheInstance.class.ts:65

### get

- get(key: string): Promise<any>

  Get a value from the cache

  #### Parameters

  - key: string

    The key to retrieve

  #### Returns Promise<any>

  The value associated with the key

  - Defined in src/Cache/CacheInstance.class.ts:36

### getTTL

- getTTL(key: string): Promise<number>

  Get the remaining TTL for a key

  #### Parameters

  - key: string

    The key to check

  #### Returns Promise<number>

  The remaining TTL in seconds

  - Defined in src/Cache/CacheInstance.class.ts:74

### `Protected` init

- init(revolveReadyPromise?: boolean): Promise<void>

  #### Parameters

  - revolveReadyPromise: boolean = true

  #### Returns Promise<void>

  Inherited from SDKObject.init

  - Defined in src/Core/SDKObject.class.ts:30

### `Protected` initSignal

- initSignal(): Promise<void>

  #### Returns Promise<void>

  Inherited from SDKObject.initSignal

  - Defined in src/Core/SDKObject.class.ts:37

### off

- off(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.off

  - Defined in src/Core/SDKObject.class.ts:49

### on

- on(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.on

  - Defined in src/Core/SDKObject.class.ts:41

### once

- once(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.once

  - Defined in src/Core/SDKObject.class.ts:53

### removeListener

- removeListener(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.removeListener

  - Defined in src/Core/SDKObject.class.ts:56

### set

- set(key: string, data: any, ttl?: number): Promise<boolean>

  Set a value in the cache

  #### Parameters

  - key: string

    The key to set

  - data: any

    The data to store

  - `Optional` ttl: number

    Optional Time To Live in seconds

  #### Returns Promise<boolean>

  true if successful

  - Defined in src/Cache/CacheInstance.class.ts:47

### updateTTL

- updateTTL(key: string, ttl?: number): Promise<void>

  Update the TTL for a key

  #### Parameters

  - key: string

    The key to update

  - `Optional` ttl: number

    New Time To Live in seconds

  #### Returns Promise<void>

  - Defined in src/Cache/CacheInstance.class.ts:83