Comments (18)
Hi All - Keyv Hooks are now up and running and we will be releasing v5.0.0-alpha.0 on NPM this weekend for testing. Just FYI.
from keyv.
@hugo082 - thanks and yes we are highly considering to move to a more stable model instead of using require
. Will update as we get closer to alpha versions in the next couple weeks.
from keyv.
@gperdomor - thanks for your suggestion and I will plan to look at moving @keyv/redis to the standard driver as that does make sense. Working on getting v5 out and then will look at that.
from keyv.
Hi,
Thanks for the update!
With the current version, there is an import design issue that breaks the compatibility with bundlers (used by Next.js even for backend environments). please refer to #45 for more details.
To summarize, here is the part of the code that is responsible of the compatibility break. We are using require(adapters[adapter])
which is a require with expression and produces the following warning: the request of a dependency is an expression
.
Is it possible to upgrade the v5 to be compatible with bundlers and remove this part of the code? It will produce a breaking change similar to:
import KeyvMemcache from '@keyv/memcache';
import Keyv from 'keyv';
// don't work anymore
const keyv = new Keyv('memcache://user:pass@localhost:11211');
// works
const keyv = new Keyv({ store: new KeyvMemcache('memcache://user:pass@localhost:11211') });
// proposals
const keyv = new Keyv(new KeyvMemcache('memcache://user:pass@localhost:11211'));
const keyv = new Keyv(KeyvMemcache, 'memcache://user:pass@localhost:11211');
from keyv.
Awesome progress, looking forward to seeing v5!
from keyv.
Awesome progress, looking forward to seeing v5!
@lukechilds - thanks so much one thing we will be discussing is if we want to go with the proposal as the require()
functionality is going to cause issues with other libraries. Thoughts?
from keyv.
@hugo082 - updated with proposal
from keyv.
Added in information around hooks
and statistics
.
from keyv.
@lukechilds - thanks so much one thing we will be discussing is if we want to go with the proposal as the require() functionality is going to cause issues with other libraries. Thoughts?
Yeah if you wanna support bundling / frontend then I think probs best to remove dynamic require. I do think inferring deps via URI is pretty slick API design if it's possible to keep though. Potentially there could be some workaround that keeps the current behaviour without doing a dynamic require. Maybe some kind of shim that statically requires each dep on a best effort basis like:
storage-adaptors.js
try {
module.exports.sqlite = require('sqlite')
} catch {}
try {
module.exports.redis = require('redis')
} catch {}
then you could require the shim at runtime without error, check which storage adaptor you want to use, and return an error if it's undefined.
Potentially that could still cause issues with bundlers if they can't find redis at bundle time or whatever I'm not sure. Maybe defining them as peer deps could help? Could be worth investigating if you want to keep the URI API though.
from keyv.
But yeah if it's gonna be too much of a headache or isn't possible I think only accepting a storage adapter instance makes sense like:
const keyv = new Keyv({ store: storageAdaptor })
from keyv.
Potentially that could still cause issues with bundlers if they can't find redis at bundle time or whatever I'm not sure. Maybe defining them as peer deps could help? Could be worth investigating if you want to keep the URI API though.
The main issue I see with the try / catch
approach is that the bundle cannot statically check so will try to bundle all dependencies (redis + sqlite).
There is maybe a solution to keep the same API by using TS Template literal types (which was introduced in typescript 4.1). I'm not sure it works but it may looks like
type SQLiteURI = `sqlite://${string}`;
type RedisURI = `redis://${string}`;
type URI = SQLiteURI | RedisURI;
const isRedisUri = (uri: URI): uri is RedisURI => uri.startsWith('redis://');
const isSQLiteUri = (uri: URI): uri is SQLiteURI => uri.startsWith('sqlite://');
const uri = 'redis://...'; // <= as to be a literal type, not only string
const clientFromUri = async (uri: URI) => {
if (isRedisUri(uri)) {
return await import('sqlite')
} else if (isSQLiteUri(uri)) {
return await import('redis')
}
assertType<never>(uri);
};
But it will still create a breaking change as the uri
property as to be a literal type URI
, not a string
from keyv.
Hi All - I wanted to update you on the progress leading up to v5 release. We have now split the repo into two branches:
- main - this is now the
v5
branch and we will be adding to it there. We do plan to put a link to the v4 branch. - v4 - this is now the
v4
branch and the goal is to maintain this through 2024.
The current branch is now completely in typescript and also has updated types. Our next step is to work on publishing the v5 alpha version for people to start testing and then roll out the rest of the features hooks, stats, browser compatibility, compression fixes, offline / tiering mode (multi storage adapters), and namespace enhancements.
from keyv.
Hi all... I just discover this package and looks awesome... I have on doubt, any particular reason why you use ioredis instead official redis package?
Maybe the V5 can introduce a new store with the official package?
from keyv.
@jaredwray or maybe rename the current redis implementation to @keyv/ioredis
in v5, in that way a new package @keyv/redis
with official redis package can be created, I can help if you want :D
from keyv.
Hi again @jaredwray, it's me again... I want to know if there is any update regarding to the V5 release or if existe any beta version available?
from keyv.
seems like ioredis eventually will be deprecated according to this comment, so now it's more important a node-redid adapter ππ» redis/ioredis#1870 (comment)
from keyv.
seems like ioredis eventually will be deprecated according to this comment, so now it's more important a node-redid adapter ππ» redis/ioredis#1870 (comment)
Correct and we will be moving to the redis driver
from keyv.
Hi All! Wanted to update this thread as https://www.npmjs.com/package/keyv/v/5.0.0-rc.1 is now published as next
and you can download it via npm install keyv@next
to get the latest. Please note, you will also want to use the latest storage adapters if using typescript as it is compatible with v5. We will be publishing them over the next 24 hours and will tag the storage adapters with next
. π
This includes ESM and CJS support (CJS will get phased out most likely with Keyv v6), hooks, statistics, and moving to async/await with typescript and the following breaking change:
URI and Proposed Breaking Change π₯
After feedback from the community and looking into this more (thanks @hugo082) we have decided to longer support the uri on the constructor. This would be a major breaking change π¬ but we believe everything else will be worth it.
import KeyvMemcache from '@keyv/memcache';
import Keyv from 'keyv';
// don't work anymore
const keyv = new Keyv('memcache://user:pass@localhost:11211');
// works
const keyv = new Keyv({ store: new KeyvMemcache('memcache://user:pass@localhost:11211') });
// proposals moving forward.
const keyv = new Keyv(new KeyvMemcache('memcache://user:pass@localhost:11211'));
const keyv = new Keyv(KeyvMemcache, 'memcache://user:pass@localhost:11211');
const keyv = new Keyv({ store: new KeyvMemcache('memcache://user:pass@localhost:11211') });
Finally, After more consideration we are going to get v5 live and past RC (we are planning that to be in June after testing) the plan moving forward is to do the final feature sets since they are non-breaking.
I will be closing this thread down and adding issues for the following features when it makes sense to track:
- Storage Tiering - we are considering not adding this in because it seems to really be a feature that we want to support in caching systems such as
cache-manager
andcacheable
long term but would love your feedback π or π - Namespacing - this is currently being planned out and should be non breaking change but will be later.
- Simplified Compression Adapters - this will be added as an enhancement as time permits this year.
from keyv.
Related Issues (20)
- Data not being stored using KeyvRedis - Issue With Typescript HOT 3
- Download failed HOT 1
- `@keyv/redis`: `useRedisSets` option does not take effect when providing `ioredis` instance HOT 1
- RedisJSON with Keyv HOT 5
- Use Redis UNLINK instead of Redis DEL HOT 2
- Check the namespace provided to Redis doesn not include ":" HOT 7
- MaxListenersExceededWarning: Possible EventEmitter memory leak detected. HOT 1
- flaky behaviour for the .has method HOT 5
- Strange compile error after upgrading @keyv/redis to 2.8.1 HOT 4
- How does the TTL work? HOT 1
- import or require webpack error. HOT 4
- sqlite adapter iterator stack overflows HOT 4
- SSL/TLS Support for Redis Connections HOT 3
- Support for later versions of MongoDB Node.js Driver HOT 3
- Get rid of json-buffer HOT 3
- β οΈ Critical dependency: the request of a dependency is an expression HOT 1
- Namespace will be missed using KeyvMongo HOT 2
- Support for setting multiples keys HOT 1
- Cannot find module '@keyv/sqlite' when using keyv in nextjs 14 app HOT 1
- When creating multiple instances of Keyv with postgres adapter, table creation fails and keyv not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keyv.