deploy_feedback icon indicating copy to clipboard operation
deploy_feedback copied to clipboard

[KV Feedback]: include or exclude keys from backup data

Open ianlet opened this issue 1 year ago • 2 comments

🔍

  • [X] Did you search for existing issues?

Type of feedback

Feature request

Description

When enabling automatic backup to S3/Google Cloud Storage, being able to configure which data should be included/excluded in the backup could be helpful to avoid storing non-relevant data.

Additional context

We currently use Deno KV both as a persistence and as a cache system. While we would like our persistence data to be backed up, we're not really interested in backing up cache data. All of our cache entries are prefixed with the key ["cache", ...] so it would be easy for us to simply exclude keys starting with cache if such feature would be available.

ianlet avatar Dec 20 '24 15:12 ianlet

Good suggestion, thank you!

Would the Web Cache API be a suitable replacement instead of KV as your cache? https://deno.com/blog/deploy-cache-api or is there something that's missing there?

Thanks! Will

willnewby avatar Dec 26 '24 18:12 willnewby

This could indeed be interesting for several use cases we have, thanks for sharing!

The only exceptions would be when we need a more granular level to cache primitive values obtained from sources that are not related to a request (e.g. heavy function calls).

For reference, our cache looks like this:

export type CacheKey = string[];
export type CacheValue = 
 | string
 | number
 | boolean
 | null
 | CacheValue[]
 | {[key: string]: CacheValue}

export interface CacheOptions {
  /** Expiration time in milliseconds */
  expireIn?: number;
}

export interface Cache {
  has(key: CacheKey): Promise<boolean>;
  read<T = CacheValue>(key: CacheKey): Promise<T | null>;
  write<T = CacheValue>(
    key: CacheKey,
    value: T,
    options?: CacheOptions,
  ): Promise<void>;
}

ianlet avatar Dec 26 '24 19:12 ianlet