Skip to content
This repository has been archived by the owner. It is now read-only.
[Migrated to nestcloud repository]A Memcached module for Nest framework (node.js)
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib update nest version Mar 19, 2019
.eslintrc.js initial commit May 12, 2018
.gitignore initial commit May 12, 2018
.npmignore
.prettierrc 0.2.0 Jun 12, 2018
README.md
index.d.ts 0.2.0 Jun 12, 2018
index.js 0.2.0 Jun 12, 2018
index.ts.js 0.2.0 Jun 12, 2018
package.json update nest version Mar 19, 2019
tsconfig.json public pkg to nestcloud org & remove old code Mar 5, 2019
tslint.json initial commit May 12, 2018
yarn.lock update nest version Mar 19, 2019

README.md

Nest Logo

Description

This is a Memcached module for Nest.

Installation

$ npm i --save @nestcloud/memcached memcached

Quick Start

Import Module

import { Module } from '@nestjs/common';
import { MemcachedModule } from '@nestcloud/memcached';

@Module({
  imports: [
      MemcachedModule.register({
        uri: [
           '192.168.0.102:11211',
           '192.168.0.103:11211',
           '192.168.0.104:11211'
        ],
        retries: 3
      })
  ],
})
export class ApplicationModule {}

If you use @nestcloud/boot module.

import { Module } from '@nestjs/common';
import { MemcachedModule } from '@nestcloud/memcached';
import { BootModule } from '@nestcloud/boot';
import { NEST_BOOT } from '@nestcloud/common';

@Module({
  imports: [
      BootModule.register(__dirname, 'bootstrap.yml'),
      MemcachedModule.register({dependencies: [NEST_BOOT]})
  ],
})
export class ApplicationModule {}
bootstrap.yml
memcached:
  uri: ['192.168.0.102:11211', '192.168.0.103:11211', '192.168.0.104:11211'],
  retries: 3

If you use @nestcloud/consul-config module.

import { Module } from '@nestjs/common';
import { MemcachedModule } from '@nestcloud/memcached';
import { ConsulModule } from '@nestcloud/consul';
import { ConsulConfigModule } from '@nestcloud/consul-config';
import { NEST_CONSUL_CONFIG } from '@nestcloud/common';

@Module({
  imports: [
      ConsulModule.register({/* ignore */}),
      ConsulConfigModule.register({/* ignore */}),
      MemcachedModule.register({dependencies: [NEST_CONSUL_CONFIG]})
  ],
})
export class ApplicationModule {}
config in consul kv
memcached:
  uri: ['192.168.0.102:11211', '192.168.0.103:11211', '192.168.0.104:11211'],
  retries: 3

Memcached Client Injection

import { Component } from '@nestjs/common';
import { InjectMemcachedClient, Memcached } from '@nestcloud/memcached';

@Component()
export class TestService {
  constructor(@InjectMemcachedClient() private readonly memClient: Memcached) {}

  async addValue(key: string, value: string): void {
      await this.memClient.add(key, value);
  }
  
  async deleteValue(key: string): void {
      await this.memClient.del(key);
  }
}

Support

NestCloud is an MIT-licensed open source project.

Stay in touch

License

NestCloud is MIT licensed.

You can’t perform that action at this time.