-
Notifications
You must be signed in to change notification settings - Fork 24
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge injection token for cache and cache instance #253
Comments
I think the the "issue" with having that indirection ( 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 |
yes, I think either way is ok, it's just better to import 1 thing from 1 lib than 2 things from 2 libs |
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 |
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. |
We already use peerDeps, so as long as |
We could fix this up by adding the extra |
Let's track this here #256 |
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
for now we inject cacheManager in this way
which is hard to remember or code, because:
The
Cache
class is imported from thecache-manager
, whileCACHE_MANAGER
token from the@nestjs/cache-manager
package.Describe the solution you'd like
we can simply wrap the
Cache
fromcache-manager
withthis solution is not following correct structure, just to demonstrate my idea
Teachability, documentation, adoption, migration strategy
existing code will not be affected, all we need to do is to update documentation and mark CACHE_MANAGER as deprecated?
What is the motivation / use case for changing the behavior?
the motivation is that we can simplify our injection code to
which is much easier and cleanner
and even more, we can avoid the
@Inject(NestCache)
by make NestCache a class that implement cache-manager'sCache
The text was updated successfully, but these errors were encountered: