Comments (7)
I think the the "issue" with having that indirection (NestCache
type) is that isn't that clear that the cache manager is from cache-manager
lib. But I'm fine with abstracting it away
Also, I'd suggest this one instead:
import { Cache } from '@nestjs/cache-manager';
@Controller()
export class Foo {
constructor(private cacheManager: Cache) {} // no need to recall the token
from cache-manager.
I think the the "issue" with having that indirection (
NestCache
type) is that isn't that clear that the cache manager is fromcache-manager
lib. But I'm fine with abstracting it awayAlso, I'd suggest this one instead:
import { Cache } from '@nestjs/cache-manager'; @Controller() export class Foo { constructor(private cacheManager: Cache) {} // no need to recall the tokenyeah, it works
yes, I think either way is ok, it's just better to import 1 thing from 1 lib than 2 things from 2 libs
from cache-manager.
Personally, I would rather import the specific token from the Nest wrapper and the actual type from the implementation library. Yes, it's another library to have to worry about, in terms of making sure it comes from the right place, but it also means that Nest can use peerDependencies
for the library and allow devs to install whichever version of the library it needs, meaning less maintenance on our side when updates are released.
from cache-manager.
We could fix this up by adding the extra useExisting
provider (= thus not introducing any breaking changes)
from cache-manager.
Personally, I would rather import the specific token from the Nest wrapper and the actual type from the implementation library. Yes, it's another library to have to worry about, in terms of making sure it comes from the right place, but it also means that Nest can use
peerDependencies
for the library and allow devs to install whichever version of the library it needs, meaning less maintenance on our side when updates are released.
From my understanding, this library is tightly related to cache-manager and it's appropriate to link cache manager as a peer dependency. It will cause trouble when user installed very old or very new versions, if he didn't know what the version that @nest/cache-manager is actually using.
from cache-manager.
We already use peerDeps, so as long as cache-manager<=5
is installed, this library will work. If we set to dependencies
then npm/yarn/pnpm will auto-install the package
from cache-manager.
Let's track this here #256
from cache-manager.
Related Issues (15)
- Using CacheInterceptor on endpoint and returning classes using class-validator decorators and applying @Excluded() decorator is not excluding the attribute in the cached response. HOT 1
- Set with CacheStoreSetOptions doesn't set correct TTL HOT 1
- Existing multicaching support not exposed in types HOT 4
- CacheModule.register() missing type for store property for redisStore HOT 1
- CacheModule in multiple modules not loading the config properly HOT 1
- Need detailed Error when set cache key. HOT 3
- Dependency Dashboard
- The register method of CacheModel does not utilize the useClass specified HOT 1
- Dynamic cache key HOT 1
- TypeError: ttl must be a positive integer if specified HOT 1
- Cache prefix HOT 1
- Implement cache client event listeners HOT 3
- Set `ttl` via `this.cacheManager.set` is not working when `ttl` is set in `CacheModule.registerAsync` as global HOT 1
- Customize CacheKey according to request parameters HOT 1
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 cache-manager.