{"id":387455,"date":"2024-06-29T07:19:25","date_gmt":"2024-06-29T07:19:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=387455"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T07:19:25","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=387455","title":{"rendered":"<span>Mongoose + Redis. \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430 5 \u043c\u0438\u043d\u0443\u0442<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<ol>\n<li>\n<p><strong>Mongoose<\/strong> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e <strong>ODM<\/strong>-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 (<strong><em>O<\/em><\/strong><em>bject <\/em><strong><em>D<\/em><\/strong><em>ata <\/em><strong><em>M<\/em><\/strong><em>odelling<\/em>) \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 MongoDB, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.\u00a0<\/p>\n<\/li>\n<li>\n<p>Redis (<strong><em>Re<\/em><\/strong><em>mote\u00a0<\/em><strong><em>Di<\/em><\/strong><em>ctionary\u00a0<\/em><strong><em>S<\/em><\/strong><em>erver<\/em>)- \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u0430 \u00ab\u043a\u043b\u044e\u0447\u2011\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u00bb \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u0430\u0439\u0434\u0430 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0432\u044f\u0437\u043a\u0443 <em>Mongoose + Redis<\/em> \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0428\u0430\u0433 1. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/strong><\/p>\n<p><code>yarn add redis mongoose<\/code><\/p>\n<p><strong>\u0428\u0430\u0433 2. \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f Redis.<\/strong><\/p>\n<pre><code class=\"javascript\">const redisUrl = process.env.REDIS_CACHE_URL const client = redis.createClient(redisUrl) client.get = util.promisify(client.get)<\/code><\/pre>\n<p><strong>\u0428\u0430\u0433 3. \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430<\/strong><\/p>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#8212; \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430, \u043f\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 <em>mongoose<\/em> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 <em>Query<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<ol>\n<li>\n<p><strong>mongooseCollection.name<\/strong>\u00a0 &#8212; \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p><strong>getQuery<\/strong> &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 ( \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>where<\/em>)<\/p>\n<\/li>\n<li>\n<p><strong>op<\/strong> &#8212; \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>find<\/em>)<\/p>\n<\/li>\n<li>\n<p><strong>options<\/strong> &#8212; \u043e\u043f\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 ( \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>limit<\/em> )\u00a0<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"javascript\">const key = JSON.stringify( \u00a0 { \u00a0 \u00a0 ...this.getQuery(), \u00a0 \u00a0 collection: this.mongooseCollection.name, \u00a0 \u00a0 op: this.op, \u00a0 \u00a0 options: this.options \u00a0 } )<\/code><\/pre>\n<p><strong>\u0428\u0430\u0433 4. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430<\/strong><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 Redis, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<ol>\n<li>\n<p>\u041f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p>\u041a\u044d\u0448\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"javascript\">const cacheValue = await client.get(key) if ( cacheValue ) return JSON.parse(cacheValue)  const result = await exec.apply(this, arguments) if ( result ) { \u00a0 client.set(key, JSON.stringify(result)) }  return result<\/code><\/pre>\n<p><strong>\u0428\u0430\u0433 5. \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435\u00a0<\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0448\u0430\u0433\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0432\u043c\u0435\u0441\u0442\u0435, \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <strong>exec<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb:\u00a0<\/p>\n<pre><code class=\"javascript\">module.exports = \u00a0 { \u00a0 \u00a0 applyMongooseCache() {  \u00a0 \u00a0 \u00a0 const redisUrl = process.env.REDIS_CACHE_URL \u00a0 \u00a0 \u00a0 const client = redis.createClient(redisUrl) \u00a0 \u00a0 \u00a0 client.get = util.promisify(client.get) \u00a0 \u00a0 \u00a0 const exec = mongoose.Query.prototype.exec  \u00a0 \u00a0 \u00a0 mongoose.Query.prototype.exec = async function () {  \u00a0 \u00a0 \u00a0 \u00a0 const key = JSON.stringify( \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 { \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ...this.getQuery(), \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 collection: this.mongooseCollection.name, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 op: this.op, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 options: this.options \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 } \u00a0 \u00a0 \u00a0 \u00a0 )  \u00a0 \u00a0 \u00a0 \u00a0 const cacheValue = await client.get(key) \u00a0 \u00a0 \u00a0 \u00a0 if ( cacheValue ) return JSON.parse(cacheValue)  \u00a0 \u00a0 \u00a0 \u00a0 const result = await exec.apply(this, arguments)  \u00a0 \u00a0 \u00a0 \u00a0 if ( result ) { \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 client.set(key, JSON.stringify(result)) \u00a0 \u00a0 \u00a0 \u00a0 }  \u00a0 \u00a0 \u00a0 \u00a0 return result \u00a0 \u00a0 \u00a0 } \u00a0 \u00a0 }, \u00a0 }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>applyMongooseCache\u00a0<\/strong> \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0412\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0<\/p>\n<p><strong>\u0428\u0430\u0433 6. Docker-compose \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0434\u0432\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430:<\/p>\n<ol>\n<li>\n<p><strong>MongoDB<\/strong>\u00a0<\/p>\n<\/li>\n<li>\n<p><strong>Redis<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>Mongo Express<\/strong> &#8212; \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <em>MongoDB<\/em><\/p>\n<\/li>\n<li>\n<p><strong>Redis admin &#8212; <\/strong>\u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <em>Redis<\/em><\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"yaml\">version: '3' services: \u00a0 mongo: \u00a0 \u00a0 image: mongo \u00a0 \u00a0 restart: always \u00a0 \u00a0 environment: \u00a0 \u00a0 \u00a0 MONGO_INITDB_ROOT_USERNAME: root \u00a0 \u00a0 \u00a0 MONGO_INITDB_ROOT_PASSWORD: root \u00a0 \u00a0 ports: \u00a0 \u00a0 \u00a0 - 27017:27017  \u00a0 mongo-express: \u00a0 \u00a0 image: mongo-express:0.54 \u00a0 \u00a0 restart: always \u00a0 \u00a0 ports: \u00a0 \u00a0 \u00a0 - 8081:8081 \u00a0 \u00a0 environment: \u00a0 \u00a0 \u00a0 ME_CONFIG_MONGODB_ADMINUSERNAME: root \u00a0 \u00a0 \u00a0 ME_CONFIG_MONGODB_ADMINPASSWORD: root \u00a0 \u00a0 depends_on: \u00a0 \u00a0 \u00a0 - mongo  \u00a0 redis: \u00a0 \u00a0 image: redis \u00a0 \u00a0 ports: \u00a0 \u00a0 \u00a0 - 6379:6379  \u00a0 redis-admin: \u00a0 \u00a0 image: erikdubbelboer\/phpredisadmin \u00a0 \u00a0 ports: \u00a0 \u00a0 \u00a0 - 8085:80 \u00a0 \u00a0 depends_on: \u00a0 \u00a0 \u00a0 - redis \u00a0 \u00a0 environment: \u00a0 \u00a0 \u00a0 REDIS_1_HOST: redis \u00a0 \u00a0 \u00a0 REDIS_1_NAME: redis \u00a0 \u00a0 \u00a0 REDIS_1_PORT: 6379<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0430\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u0412\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 <em>27017<\/em>(<strong>mongo<\/strong>) \u0438\u00a0 <em>6379<\/em> (<strong>Redis<\/strong>) \u043f\u043e\u0440\u0442\u0430\u0445.<\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 <em>8081<\/em> ( <strong>mongo-express<\/strong>) \u0438 <em>8085<\/em> (<strong>Redis admin<\/strong>) \u043f\u043e\u0440\u0442\u0430\u0445.\u00a0<\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439: <a href=\"https:\/\/github.com\/IAlexanderI1994\/mongoose-redis\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/IAlexanderI1994\/mongoose-redis<\/a><\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0412\u0430\u0441 \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u0412\u0430\u0448\u0438\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c.\u00a0<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/579036\/\"> https:\/\/habr.com\/ru\/articles\/579036\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<ol>\n<li>\n<p><strong>Mongoose<\/strong> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e <strong>ODM<\/strong>-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 (<strong><em>O<\/em><\/strong><em>bject <\/em><strong><em>D<\/em><\/strong><em>ata <\/em><strong><em>M<\/em><\/strong><em>odelling<\/em>) \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 MongoDB, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.\u00a0<\/p>\n<\/li>\n<li>\n<p>Redis (<strong><em>Re<\/em><\/strong><em>mote\u00a0<\/em><strong><em>Di<\/em><\/strong><em>ctionary\u00a0<\/em><strong><em>S<\/em><\/strong><em>erver<\/em>)- \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u0430 \u00ab\u043a\u043b\u044e\u0447\u2011\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u00bb \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u0430\u0439\u0434\u0430 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0432\u044f\u0437\u043a\u0443 <em>Mongoose + Redis<\/em> \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0428\u0430\u0433 1. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/strong><\/p>\n<p><code>yarn add redis mongoose<\/code><\/p>\n<p><strong>\u0428\u0430\u0433 2. \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f Redis.<\/strong><\/p>\n<pre><code class=\"javascript\">const redisUrl = process.env.REDIS_CACHE_URL const client = redis.createClient(redisUrl) client.get = util.promisify(client.get)<\/code><\/pre>\n<p><strong>\u0428\u0430\u0433 3. \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430<\/strong><\/p>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#8212; \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430, \u043f\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 <em>mongoose<\/em> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 <em>Query<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<ol>\n<li>\n<p><strong>mongooseCollection.name<\/strong>\u00a0 &#8212; \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p><strong>getQuery<\/strong> &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 ( \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>where<\/em>)<\/p>\n<\/li>\n<li>\n<p><strong>op<\/strong> &#8212; \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>find<\/em>)<\/p>\n<\/li>\n<li>\n<p><strong>options<\/strong> &#8212; \u043e\u043f\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 ( \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>limit<\/em> )\u00a0<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"javascript\">const key = JSON.stringify( \u00a0 { \u00a0 \u00a0 ...this.getQuery(), \u00a0 \u00a0 collection: this.mongooseCollection.name, \u00a0 \u00a0 op: this.op, \u00a0 \u00a0 options: this.options \u00a0 } )<\/code><\/pre>\n<p><strong>\u0428\u0430\u0433 4. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430<\/strong><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 Redis, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<ol>\n<li>\n<p>\u041f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p>\u041a\u044d\u0448\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"javascript\">const cacheValue = await client.get(key) if ( cacheValue ) return JSON.parse(cacheValue)  const result = await exec.apply(this, arguments) if ( result ) { \u00a0 client.set(key, JSON.stringify(result)) }  return result<\/code><\/pre>\n<p><strong>\u0428\u0430\u0433 5. \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435\u00a0<\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0448\u0430\u0433\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0432\u043c\u0435\u0441\u0442\u0435, \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <strong>exec<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb:\u00a0<\/p>\n<pre><code class=\"javascript\">module.exports = \u00a0 { \u00a0 \u00a0 applyMongooseCache() {  \u00a0 \u00a0 \u00a0 const redisUrl = process.env.REDIS_CACHE_URL \u00a0 \u00a0 \u00a0 const client = redis.createClient(redisUrl) \u00a0 \u00a0 \u00a0 client.get = util.promisify(client.get) \u00a0 \u00a0 \u00a0 const exec = mongoose.Query.prototype.exec  \u00a0 \u00a0 \u00a0 mongoose.Query.prototype.exec = async function () {  \u00a0 \u00a0 \u00a0 \u00a0 const key = JSON.stringify( \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 { \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ...this.getQuery(), \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 collection: this.mongooseCollection.name, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 op: this.op, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 options: this.options \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 } \u00a0 \u00a0 \u00a0 \u00a0 )  \u00a0 \u00a0 \u00a0 \u00a0 const cacheValue = await client.get(key) \u00a0 \u00a0 \u00a0 \u00a0 if ( cacheValue ) return JSON.parse(cacheValue)  \u00a0 \u00a0 \u00a0 \u00a0 const result = await exec.apply(this, arguments)  \u00a0 \u00a0 \u00a0 \u00a0 if ( result ) { \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 client.set(key, JSON.stringify(result)) \u00a0 \u00a0 \u00a0 \u00a0 }  \u00a0 \u00a0 \u00a0 \u00a0 return result \u00a0 \u00a0 \u00a0 } \u00a0 \u00a0 }, \u00a0 }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>applyMongooseCache\u00a0<\/strong> \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0412\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0<\/p>\n<p><strong>\u0428\u0430\u0433 6. Docker-compose \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0434\u0432\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430:<\/p>\n<ol>\n<li>\n<p><strong>MongoDB<\/strong>\u00a0<\/p>\n<\/li>\n<li>\n<p><strong>Redis<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>Mongo Express<\/strong> &#8212; \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <em>MongoDB<\/em><\/p>\n<\/li>\n<li>\n<p><strong>Redis admin &#8212; <\/strong>\u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <em>Redis<\/em><\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"yaml\">version: '3' services: \u00a0 mongo: \u00a0 \u00a0 image: mongo \u00a0 \u00a0 restart: always \u00a0 \u00a0 environment: \u00a0 \u00a0 \u00a0 MONGO_INITDB_ROOT_USERNAME: root \u00a0 \u00a0 \u00a0 MONGO_INITDB_ROOT_PASSWORD: root \u00a0 \u00a0 ports: \u00a0 \u00a0 \u00a0 - 27017:27017  \u00a0 mongo-express: \u00a0 \u00a0 image: mongo-express:0.54 \u00a0 \u00a0 restart: always \u00a0 \u00a0 ports: \u00a0 \u00a0 \u00a0 - 8081:8081 \u00a0 \u00a0 environment: \u00a0 \u00a0 \u00a0 ME_CONFIG_MONGODB_ADMINUSERNAME: root \u00a0 \u00a0 \u00a0 ME_CONFIG_MONGODB_ADMINPASSWORD: root \u00a0 \u00a0 depends_on: \u00a0 \u00a0 \u00a0 - mongo  \u00a0 redis: \u00a0 \u00a0 image: redis \u00a0 \u00a0 ports: \u00a0 \u00a0 \u00a0 - 6379:6379  \u00a0 redis-admin: \u00a0 \u00a0 image: erikdubbelboer\/phpredisadmin \u00a0 \u00a0 ports: \u00a0 \u00a0 \u00a0 - 8085:80 \u00a0 \u00a0 depends_on: \u00a0 \u00a0 \u00a0 - redis \u00a0 \u00a0 environment: \u00a0 \u00a0 \u00a0 REDIS_1_HOST: redis \u00a0 \u00a0 \u00a0 REDIS_1_NAME: redis \u00a0 \u00a0 \u00a0 REDIS_1_PORT: 6379<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0430\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u0412\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 <em>27017<\/em>(<strong>mongo<\/strong>) \u0438\u00a0 <em>6379<\/em> (<strong>Redis<\/strong>) \u043f\u043e\u0440\u0442\u0430\u0445.<\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 <em>8081<\/em> ( <strong>mongo-express<\/strong>) \u0438 <em>8085<\/em> (<strong>Redis admin<\/strong>) \u043f\u043e\u0440\u0442\u0430\u0445.\u00a0<\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439: <a href=\"https:\/\/github.com\/IAlexanderI1994\/mongoose-redis\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/IAlexanderI1994\/mongoose-redis<\/a><\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0412\u0430\u0441 \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u0412\u0430\u0448\u0438\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c.\u00a0<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/579036\/\"> https:\/\/habr.com\/ru\/articles\/579036\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-387455","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/387455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=387455"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/387455\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=387455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=387455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=387455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}