
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
kysely-cache
Advanced tools
Kysely Cache plugin; with this plugin you can cache a query and make next queries faster, that will not go directly to the database, but will be getted from the cache. This plugin has three different implementation KyselyLRUSQLCache, KyselyLRUCache and KyselyLRUKeyVCache.
npm i kysely kysely-cache
Description
This cache stores data inside a DB (sqlite, mysql or postgres) and sets a cached query (and results) lifetime (ttl) and a maximum number of queries (and elements)
Options
Api
How to use
const sqliteDialect = new SqliteDialect({ database: new Database(':memory:')})
const kyselyInstance = new Kysely<Database>({ dialect: sqliteDialect })
await kyselyInstance.schema
.createTable('person')
.addColumn('id', 'integer', (col) => col.primaryKey())
.addColumn('first_name', 'varchar(255)')
.addColumn('last_name', 'varchar(255)')
.addColumn('gender', 'varchar(255)')
.execute()
await kyselyInstance
.insertInto('person')
.values({
first_name: 'Max',
last_name: 'Jack',
gender: 'man',
})
.execute()
const kyselyLRUSQLCacheInstance = await KyselyLRUSQLCache.createCache<Database>(opt.config)
const queryBuilderSelectFrom = kyselyInstance
.selectFrom('person')
.selectAll()
const people = await kyselyLRUSQLCacheInstance.execute(queryBuilderSelectFrom)
Description
This cache keeps data in memory (inside an object) and sets a cache query (and results) lifetime (ttl) and a maximum number of queries (and elements)
Options
Api
How to use
const sqliteDialect = new SqliteDialect( { database: new Database(':memory:') } )
const kyselyInstance = new Kysely<Database>( { dialect: sqliteDialect } )
await kyselyInstance.schema.createTable('person')
.addColumn('id', 'integer', (col) => col.primaryKey())
.addColumn('first_name', 'varchar(255)')
.addColumn('last_name', 'varchar(255)')
.addColumn('gender', 'varchar(255)')
.execute()
await kyselyInstance.insertInto('person').values( { first_name: 'Max', last_name: 'Jack', gender: 'man' } )
.execute()
const kyselyLRUCacheInstance = KyselyLRUCache.createCache<Database>( { max: 50, ttl: 60000 } )
const kyselySelectQueryBuilderOne = kyselyInstance.selectFrom('person').selectAll()
const persone = await KyselyLRUCacheInstance.executeTakeFirstOrThrow(kyselySelectQueryBuilderOne)
Description
This cache keeps data using KeyV storage, with this cache you have to use KeyV options of the different stores
This cache needs KeyV!
npm i --save keyv
Options
Api
How to use
const sqliteDialect = new SqliteDialect( { database: new Database(':memory:') } )
const kyselyInstance = new Kysely<Database>( { dialect: sqliteDialect } )
await kyselyInstance.schema.createTable('person')
.addColumn('id', 'integer', (col) => col.primaryKey())
.addColumn('first_name', 'varchar(255)')
.addColumn('last_name', 'varchar(255)')
.addColumn('gender', 'varchar(255)')
.execute()
await kyselyInstance.insertInto('person').values( { first_name: 'Max', last_name: 'Jack', gender: 'man' } )
.execute()
const kyselyLRUCacheInstance = KyselyLRUKeyVCacheInstance.createCache<Database>( { ttl: 60000 } )
const kyselySelectQueryBuilderOne = kyselyInstance.selectFrom('person').selectAll()
const persone = await kyselyLRUCacheInstance.executeTakeFirstOrThrow(kyselySelectQueryBuilderOne)
Licensed under MIT.
FAQs
Cache layer for kysely
The npm package kysely-cache receives a total of 0 weekly downloads. As such, kysely-cache popularity was classified as not popular.
We found that kysely-cache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.