IT |
ITmedia 総合記事一覧 |
[ITmedia News] 前評判を覆し「FF16」の期待値を跳ね上げた体験版の“とんでもない中身” マンガ家も体験 |
https://www.itmedia.co.jp/news/articles/2306/18/news040.html
|
finalfantasyxvi |
2023-06-18 09:40:00 |
TECH |
Techable(テッカブル) |
広がる都市農。プランティオ、野菜栽培のアドバイスをするAI搭載のIoTセンサーを1,000台量産へ |
https://techable.jp/archives/211893
|
株式会社 |
2023-06-18 00:30:55 |
TECH |
Techable(テッカブル) |
建設業向けマーケティングツール、SEO対策を自動化する「AIキーワードジェネレーター」実装 |
https://techable.jp/archives/211948
|
専門知識 |
2023-06-18 00:00:32 |
AWS |
lambdaタグが付けられた新着投稿 - Qiita |
【データ基盤構築/AWS Lambda】Pythonを使ってSnowflakeのデータをRDSにinsertする |
https://qiita.com/Ayumu-y/items/8238908ad8800718a627
|
awslam |
2023-06-18 09:46:26 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
ABC 306 備忘録 |
https://qiita.com/mae-commits/items/bb42f510acf3c9aaa8bf
|
httpsa |
2023-06-18 09:54:41 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
【データ基盤構築/AWS Lambda】Pythonを使ってSnowflakeのデータをRDSにinsertする |
https://qiita.com/Ayumu-y/items/8238908ad8800718a627
|
awslam |
2023-06-18 09:46:26 |
Linux |
Ubuntuタグが付けられた新着投稿 - Qiita |
C# で ChatGPT API: AI で作曲して MIDI ファイルを作成する |
https://qiita.com/fsdg-adachi_h/items/30fbf924e1c8681863ec
|
wslubuntu |
2023-06-18 09:40:17 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
【データ基盤構築/AWS Lambda】Pythonを使ってSnowflakeのデータをRDSにinsertする |
https://qiita.com/Ayumu-y/items/8238908ad8800718a627
|
awslam |
2023-06-18 09:46:26 |
Git |
Gitタグが付けられた新着投稿 - Qiita |
[Git] 動作を試す 実行例61:checkoutで特定のフォルダ(サブモジュール等)だけを(上書き)マージする |
https://qiita.com/dl_from_scratch/items/7b83f4c3f7df1c468722
|
checkout |
2023-06-18 09:35:19 |
海外TECH |
DEV Community |
Exploring Caching with NestJS and Redis |
https://dev.to/fikkyman1/exploring-caching-with-nestjs-and-redis-56aj
|
Exploring Caching with NestJS and RedisIn this tutorial we will be exploring the world of caching with NestJS and Redis Before we dive head in into Redis NestJS provides its in memory cache that can serve as an in memory data store but can easily be switched to high performant caching system like Redis To get started you can fork this github repository Please ensure you select the base branch as it contains the base application setup for this tutorial After setting up you base application setup you can proceed to install the cache manager package and its dependencies npm install nestjs cache manager cache managerIn case you are familiar with NestJS in memory cache implementation there is a current update to the cache manager we are using version throughout this tutorial As opposed to the version the version now provides ttl Time To Live in milliseconds instead We have to do the conversion before parsing it to NestJS as NestJs does not do the conversion for us To enable caching we have to import the CacheModule into the app module ts file import Module from nestjs common import AppController from app controller import AppService from app service import MongooseModule from nestjs mongoose import ContactModule from contact contact module import CacheModule from nestjs cache manager Module imports mongodb nest redis use env variables or other secure options in production MongooseModule forRoot mongodb nest redis useNewUrlParser true ContactModule CacheModule register controllers AppController providers AppService export class AppModule Our app module ts file should look like the one above We are also going to import it into our Contact module With any feature module in NestJS there is a need to import the cache manager into them respectively If you have a module that does not require caching then it is not a necessity Our contact module ts should be similar to the code block below import Module from nestjs common import ContactService from contact service import ContactController from contact controller import MongooseModule from nestjs mongoose import ContactSchema from schemas schema import CacheModule from nestjs cache manager Module imports MongooseModule forFeature name Contact schema ContactSchema CacheModule register providers ContactService controllers ContactController export class ContactModule A good alternative is setting the isGlobal option for the CacheModule register This option can be considered if you need caching availability across all your modules Let s proceed to our Contact controller to modify some of our existing endpoints For the Get contacts contactId endpoint we want to check if our response is in cache before calling the method This is achievable using the useInterceptors decorator Our getContact method should be similar to this below UseInterceptors CacheInterceptor Automatically cache the response for this endpoint Get contacts contactId async getContact Res res Param contactId contactId const contact await this contactService getContact contactId if contact throw new NotFoundException Contact does not exist return res status HttpStatus OK json contact Things to note The expiry time is secondsThe interceptor autogenerates the cache key for the cache entry based on the route path Both options can be effectively controlled and overriden Implementing an override our getContact will be UseInterceptors CacheInterceptor Automatically cache the response for this endpoint CacheKey getcontact key CacheTTL now in milliseconds minute Get contacts contactId async getContact Res res Param contactId contactId const contact await this contactService getContact contactId if contact throw new NotFoundException Contact does not exist return res status HttpStatus OK json contact According to the official Nestjs documentation the CacheModule will not work properly with GraphQL applications Now RedisAccording to the official Redis website “Redis is an open source in memory data structure store used as a database cache message broker and streaming engine Polled from RedisTo use Redis instead of the in memory cache we will need to install the relevant package npm i save cache manager redis yetThis package is a nestjs wrapper for passing configurations to the node redis package We can now change some config of our app module ts to use Redis Note cache manager redis store is been discontinued to allow for the package we just installed This package we installed is been tracked directly by the Nestjs team import Module from nestjs common import AppController from app controller import AppService from app service import MongooseModule from nestjs mongoose import ContactModule from contact contact module import CacheModule from nestjs cache manager import redisStore from cache manager redis yet Module imports MongooseModule forRoot mongodb nest redis useNewUrlParser true CacheModule registerAsync isGlobal true useFactory async gt store await redisStore socket host localhost port ContactModule controllers AppController providers AppService export class AppModule This has allowed us to add new config options like redisStore represent the node cache manager redis yet we just installed host and port are set to their defaultIncase you don t have Redis server running yet you can look up various installation methods for your operating system or consider the Docker optionHeading to our contact controller page we can configure our getContact method to check if we have a cached data yet before querying the main database If it exists we want to return it else we want to set it after querying the DB Our getContact should be similar to this Get contacts contactId async getContact Res res Param contactId contactId const cachedData await this cacheService get contactId toString if cachedData console log Getting data from cache return res status HttpStatus OK json cachedData const contact await this contactService getContact contactId if contact throw new NotFoundException Contact does not exist await this cacheService set contactId toString contact const newCachedData await this cacheService get contactId toString console log data set to cache newCachedData return res status HttpStatus OK json contact Let s take a brief look at the code block above const cachedData await this cacheService get contactId toString if cachedData console log Getting data from cache return res status HttpStatus OK json cachedData The cachedData variable is checking if we have an existing cache if it exists you can check your logger and you ll get Getting data from cache await this cacheService set contactId toString contact const newCachedData await this cacheService get contactId toString console log data set to cache newCachedData If our data does not exist in cache the codeblock above helps us to set in cache Your cached data will now persist to your local Redis server You can test out the endpoint and you should get a result similar to my output in your logger Nest AM LOG NestApplication Nest application successfully started msdata set to cache id cfcbaaa first name Daniel last name Olabemiwo email dee gmail com phone message Welcome to this side v You can confirm in your GUI of choice I like TablePlus by sending a request to your NestJS app where caching is used and you ll see the data is now persisted Congratulations you have just added a Redis cache to your NestJS application In this tutorial we have successfully added a Redis cache to our Nestjs application Redis enables lower application latency and very high data access This allows software engineers to build highly performant reliable solutions And that s it What do you think Let me know in the comments below |
2023-06-18 00:41:16 |
ニュース |
BBC News - Home |
The Papers: William to end homelessness, and more Partygate revelations |
https://www.bbc.co.uk/news/blogs-the-papers-65941581?at_medium=RSS&at_campaign=KARANGA
|
wales |
2023-06-18 00:28:13 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
【医師が教える】清涼飲料水に含まれる“猛毒”ともいえる要注意の成分[見逃し配信・6月第3週] - 書籍オンライン編集部から |
https://diamond.jp/articles/-/324653
|
清涼飲料水 |
2023-06-18 10:00:00 |
ビジネス |
東洋経済オンライン |
フリーライター45歳の彼女が「離婚」で得たもの 「男が女を養うもの」という価値観が変わった | 離婚のリアル | 東洋経済オンライン |
https://toyokeizai.net/articles/-/678999?utm_source=rss&utm_medium=http&utm_campaign=link_back
|
東洋経済オンライン |
2023-06-18 09:30:00 |
ビジネス |
東洋経済オンライン |
吉川ひなの「母を許せない自分」を許すことから 「許す神話」は、自分を歪めてしまう一因にも | 家庭 | 東洋経済オンライン |
https://toyokeizai.net/articles/-/673363?utm_source=rss&utm_medium=http&utm_campaign=link_back
|
吉川ひなの |
2023-06-18 09:15:00 |
ニュース |
Newsweek |
コロナ禍明けて明暗分かれた韓国企業 デリバリーのベミン、ホンダコリア、大韓航空 |
https://www.newsweekjapan.jp/stories/world/2023/06/post-101922.php
|
例えば日本航空は、小口貨物は旅客便の貨物室でも輸送するが、大口貨物や大型貨物はJALカーゴが輸送する。 |
2023-06-18 09:45:21 |
ビジネス |
プレジデントオンライン |
プライドを捨てて「中学生向け参考書」からやり直すべき…カリスマ講師が勧める英語習得の最短ルート - いきなり英字新聞を読むのは効率が悪すぎる |
https://president.jp/articles/-/70657
|
四苦八苦 |
2023-06-18 10:00:00 |
コメント
コメントを投稿