@naman_deep_singh/cache 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/adapters/index.js +19 -0
- package/dist/cjs/adapters/memcache/MemcacheCache.js +10 -11
- package/dist/cjs/adapters/memcache/index.js +2 -2
- package/dist/cjs/adapters/memory/MemoryCache.js +14 -15
- package/dist/cjs/adapters/memory/index.js +2 -2
- package/dist/cjs/adapters/redis/RedisCache.js +15 -16
- package/dist/cjs/adapters/redis/index.js +2 -2
- package/dist/cjs/core/BaseCache.js +3 -4
- package/dist/cjs/core/factory.js +10 -13
- package/dist/cjs/core/index.js +19 -0
- package/dist/cjs/core/interfaces/index.js +16 -0
- package/dist/cjs/errors/CacheError.js +2 -2
- package/dist/cjs/errors/index.js +19 -6
- package/dist/cjs/index.js +25 -24
- package/dist/cjs/middleware/express/index.js +15 -5
- package/dist/cjs/middleware/index.js +17 -0
- package/dist/cjs/session/SessionStore.js +16 -17
- package/dist/cjs/session/index.js +15 -3
- package/dist/esm/adapters/index.js +3 -0
- package/dist/esm/adapters/memcache/MemcacheCache.js +2 -3
- package/dist/esm/adapters/memcache/index.js +1 -1
- package/dist/esm/adapters/memory/MemoryCache.js +2 -3
- package/dist/esm/adapters/memory/index.js +1 -1
- package/dist/esm/adapters/redis/RedisCache.js +2 -3
- package/dist/esm/adapters/redis/index.js +1 -1
- package/dist/esm/core/BaseCache.js +1 -2
- package/dist/esm/core/factory.js +2 -5
- package/dist/esm/core/index.js +3 -0
- package/dist/esm/core/interfaces/index.js +2 -1
- package/dist/esm/errors/CacheError.js +1 -1
- package/dist/esm/errors/index.js +4 -3
- package/dist/esm/index.js +11 -13
- package/dist/esm/middleware/express/index.js +1 -1
- package/dist/esm/middleware/index.js +1 -0
- package/dist/esm/session/SessionStore.js +1 -2
- package/dist/esm/session/index.js +1 -1
- package/dist/types/adapters/index.d.ts +3 -0
- package/dist/types/adapters/memcache/MemcacheCache.d.ts +2 -2
- package/dist/types/adapters/memcache/index.d.ts +1 -1
- package/dist/types/adapters/memory/MemoryCache.d.ts +2 -2
- package/dist/types/adapters/memory/index.d.ts +1 -1
- package/dist/types/adapters/redis/RedisCache.d.ts +2 -2
- package/dist/types/adapters/redis/index.d.ts +1 -1
- package/dist/types/core/BaseCache.d.ts +2 -2
- package/dist/types/core/factory.d.ts +2 -2
- package/dist/types/core/index.d.ts +3 -0
- package/dist/types/core/interfaces/ICache.d.ts +1 -1
- package/dist/types/core/interfaces/ISession.d.ts +1 -1
- package/dist/types/core/interfaces/index.d.ts +2 -2
- package/dist/types/errors/CacheError.d.ts +2 -2
- package/dist/types/errors/index.d.ts +2 -1
- package/dist/types/index.d.ts +6 -10
- package/dist/types/middleware/express/cacheMiddleware.d.ts +2 -2
- package/dist/types/middleware/express/index.d.ts +1 -1
- package/dist/types/middleware/index.d.ts +1 -0
- package/dist/types/session/SessionStore.d.ts +2 -2
- package/dist/types/session/index.d.ts +1 -2
- package/package.json +6 -4
- package/dist/cjs/adapters/memcache/MemcacheCache.d.ts +0 -18
- package/dist/cjs/adapters/memcache/index.d.ts +0 -1
- package/dist/cjs/adapters/memory/MemoryCache.d.ts +0 -63
- package/dist/cjs/adapters/memory/index.d.ts +0 -1
- package/dist/cjs/adapters/redis/RedisCache.d.ts +0 -67
- package/dist/cjs/adapters/redis/index.d.ts +0 -1
- package/dist/cjs/core/BaseCache.d.ts +0 -78
- package/dist/cjs/core/factory.d.ts +0 -16
- package/dist/cjs/core/interfaces/ICache.d.ts +0 -58
- package/dist/cjs/core/interfaces/ISession.d.ts +0 -30
- package/dist/cjs/core/interfaces/index.d.ts +0 -2
- package/dist/cjs/errors/CacheError.d.ts +0 -12
- package/dist/cjs/errors/cacheErrorCodes.d.ts +0 -22
- package/dist/cjs/errors/index.d.ts +0 -1
- package/dist/cjs/index.d.ts +0 -10
- package/dist/cjs/middleware/express/cacheMiddleware.d.ts +0 -22
- package/dist/cjs/middleware/express/index.d.ts +0 -1
- package/dist/cjs/session/SessionStore.d.ts +0 -57
- package/dist/cjs/session/index.d.ts +0 -2
- package/dist/cjs/types.d.ts +0 -102
- package/dist/esm/adapters/memcache/MemcacheCache.d.ts +0 -18
- package/dist/esm/adapters/memcache/index.d.ts +0 -1
- package/dist/esm/adapters/memory/MemoryCache.d.ts +0 -63
- package/dist/esm/adapters/memory/index.d.ts +0 -1
- package/dist/esm/adapters/redis/RedisCache.d.ts +0 -67
- package/dist/esm/adapters/redis/index.d.ts +0 -1
- package/dist/esm/core/BaseCache.d.ts +0 -78
- package/dist/esm/core/factory.d.ts +0 -16
- package/dist/esm/core/interfaces/ICache.d.ts +0 -58
- package/dist/esm/core/interfaces/ISession.d.ts +0 -30
- package/dist/esm/core/interfaces/index.d.ts +0 -2
- package/dist/esm/errors/CacheError.d.ts +0 -12
- package/dist/esm/errors/cacheErrorCodes.d.ts +0 -22
- package/dist/esm/errors/index.d.ts +0 -1
- package/dist/esm/index.d.ts +0 -10
- package/dist/esm/middleware/express/cacheMiddleware.d.ts +0 -22
- package/dist/esm/middleware/express/index.d.ts +0 -1
- package/dist/esm/session/SessionStore.d.ts +0 -57
- package/dist/esm/session/index.d.ts +0 -2
- package/dist/esm/types.d.ts +0 -102
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SessionStore = void 0;
|
|
4
|
-
const
|
|
5
|
-
const cacheErrorCodes_1 = require("src/errors/cacheErrorCodes");
|
|
4
|
+
const index_js_1 = require("../errors/index.js");
|
|
6
5
|
/**
|
|
7
6
|
* Session store wrapper around cache adapters
|
|
8
7
|
* Provides session management functionality
|
|
@@ -25,7 +24,7 @@ class SessionStore {
|
|
|
25
24
|
await this.cache.set(sessionId, data, ttlValue);
|
|
26
25
|
}
|
|
27
26
|
catch (error) {
|
|
28
|
-
throw new
|
|
27
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_CREATE_ERROR, {
|
|
29
28
|
adapter: 'session',
|
|
30
29
|
operation: 'create',
|
|
31
30
|
details: { sessionId },
|
|
@@ -41,7 +40,7 @@ class SessionStore {
|
|
|
41
40
|
return await this.cache.get(sessionId);
|
|
42
41
|
}
|
|
43
42
|
catch (error) {
|
|
44
|
-
throw new
|
|
43
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_GET_ERROR, {
|
|
45
44
|
adapter: 'session',
|
|
46
45
|
operation: 'get',
|
|
47
46
|
details: { sessionId },
|
|
@@ -56,7 +55,7 @@ class SessionStore {
|
|
|
56
55
|
try {
|
|
57
56
|
const current = await this.cache.get(sessionId);
|
|
58
57
|
if (!current) {
|
|
59
|
-
throw new
|
|
58
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_NOT_FOUND, {
|
|
60
59
|
adapter: 'session',
|
|
61
60
|
operation: 'update',
|
|
62
61
|
details: { sessionId },
|
|
@@ -66,10 +65,10 @@ class SessionStore {
|
|
|
66
65
|
await this.cache.set(sessionId, merged, this.options.ttl);
|
|
67
66
|
}
|
|
68
67
|
catch (error) {
|
|
69
|
-
if (error instanceof
|
|
68
|
+
if (error instanceof index_js_1.CacheError) {
|
|
70
69
|
throw error;
|
|
71
70
|
}
|
|
72
|
-
throw new
|
|
71
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_UPDATE_ERROR, {
|
|
73
72
|
adapter: 'session',
|
|
74
73
|
operation: 'update',
|
|
75
74
|
details: { sessionId },
|
|
@@ -85,7 +84,7 @@ class SessionStore {
|
|
|
85
84
|
return await this.cache.delete(sessionId);
|
|
86
85
|
}
|
|
87
86
|
catch (error) {
|
|
88
|
-
throw new
|
|
87
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_DELETE_ERROR, {
|
|
89
88
|
adapter: 'session',
|
|
90
89
|
operation: 'delete',
|
|
91
90
|
details: { sessionId },
|
|
@@ -101,7 +100,7 @@ class SessionStore {
|
|
|
101
100
|
return await this.cache.exists(sessionId);
|
|
102
101
|
}
|
|
103
102
|
catch (error) {
|
|
104
|
-
throw new
|
|
103
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_EXISTS_ERROR, {
|
|
105
104
|
adapter: 'session',
|
|
106
105
|
operation: 'exists',
|
|
107
106
|
details: { sessionId },
|
|
@@ -117,7 +116,7 @@ class SessionStore {
|
|
|
117
116
|
await this.cache.clear();
|
|
118
117
|
}
|
|
119
118
|
catch (error) {
|
|
120
|
-
throw new
|
|
119
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_CLEAR_ERROR, {
|
|
121
120
|
adapter: 'session',
|
|
122
121
|
operation: 'clear',
|
|
123
122
|
cause: error instanceof Error ? error : undefined,
|
|
@@ -132,7 +131,7 @@ class SessionStore {
|
|
|
132
131
|
return await this.cache.getMultiple(sessionIds);
|
|
133
132
|
}
|
|
134
133
|
catch (error) {
|
|
135
|
-
throw new
|
|
134
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_GET_MULTIPLE_ERROR, {
|
|
136
135
|
adapter: 'session',
|
|
137
136
|
operation: 'getMultiple',
|
|
138
137
|
cause: error instanceof Error ? error : undefined,
|
|
@@ -147,7 +146,7 @@ class SessionStore {
|
|
|
147
146
|
return await this.cache.deleteMultiple(sessionIds);
|
|
148
147
|
}
|
|
149
148
|
catch (error) {
|
|
150
|
-
throw new
|
|
149
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_DELETE_MULTIPLE_ERROR, {
|
|
151
150
|
adapter: 'session',
|
|
152
151
|
operation: 'deleteMultiple',
|
|
153
152
|
cause: error instanceof Error ? error : undefined,
|
|
@@ -161,7 +160,7 @@ class SessionStore {
|
|
|
161
160
|
try {
|
|
162
161
|
const current = await this.cache.get(sessionId);
|
|
163
162
|
if (!current) {
|
|
164
|
-
throw new
|
|
163
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_NOT_FOUND, {
|
|
165
164
|
adapter: 'session',
|
|
166
165
|
operation: 'extend',
|
|
167
166
|
details: { sessionId },
|
|
@@ -171,10 +170,10 @@ class SessionStore {
|
|
|
171
170
|
await this.cache.set(sessionId, current, ttlValue);
|
|
172
171
|
}
|
|
173
172
|
catch (error) {
|
|
174
|
-
if (error instanceof
|
|
173
|
+
if (error instanceof index_js_1.CacheError) {
|
|
175
174
|
throw error;
|
|
176
175
|
}
|
|
177
|
-
throw new
|
|
176
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_EXTEND_ERROR, {
|
|
178
177
|
adapter: 'session',
|
|
179
178
|
operation: 'extend',
|
|
180
179
|
details: { sessionId },
|
|
@@ -194,10 +193,10 @@ class SessionStore {
|
|
|
194
193
|
return data;
|
|
195
194
|
}
|
|
196
195
|
catch (error) {
|
|
197
|
-
if (error instanceof
|
|
196
|
+
if (error instanceof index_js_1.CacheError) {
|
|
198
197
|
throw error;
|
|
199
198
|
}
|
|
200
|
-
throw new
|
|
199
|
+
throw new index_js_1.CacheError(index_js_1.CACHE_ERROR_CODES.SESSION_GET_EXTEND_ERROR, {
|
|
201
200
|
adapter: 'session',
|
|
202
201
|
operation: 'getAndExtend',
|
|
203
202
|
details: { sessionId },
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
var SessionStore_1 = require("./SessionStore");
|
|
5
|
-
Object.defineProperty(exports, "SessionStore", { enumerable: true, get: function () { return SessionStore_1.SessionStore; } });
|
|
17
|
+
__exportStar(require("./SessionStore.js"), exports);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Memcached from 'memcached';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { CacheError } from '../../errors';
|
|
2
|
+
import { BaseCache } from '../../core/index.js';
|
|
3
|
+
import { CACHE_ERROR_CODES, CacheError } from '../../errors/index.js';
|
|
5
4
|
export class MemcacheCache extends BaseCache {
|
|
6
5
|
constructor(memcacheConfig) {
|
|
7
6
|
super(memcacheConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MemcacheCache } from './MemcacheCache';
|
|
1
|
+
export { MemcacheCache } from './MemcacheCache.js';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { CacheError } from '../../errors';
|
|
1
|
+
import { BaseCache } from '../../core/index.js';
|
|
2
|
+
import { CACHE_ERROR_CODES, CacheError } from '../../errors/index.js';
|
|
4
3
|
/**
|
|
5
4
|
* In-memory cache adapter for development and testing
|
|
6
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MemoryCache } from './MemoryCache';
|
|
1
|
+
export { MemoryCache } from './MemoryCache.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createClient, createCluster } from 'redis';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { CacheError } from '../../errors';
|
|
2
|
+
import { BaseCache } from '../../core/index.js';
|
|
3
|
+
import { CACHE_ERROR_CODES, CacheError } from '../../errors/index.js';
|
|
5
4
|
/**
|
|
6
5
|
* Redis cache adapter
|
|
7
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { RedisCache } from './RedisCache';
|
|
1
|
+
export { RedisCache } from './RedisCache.js';
|
package/dist/esm/core/factory.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { MemoryCache } from '../adapters/memory';
|
|
4
|
-
import { RedisCache } from '../adapters/redis';
|
|
5
|
-
import { CacheError } from '../errors';
|
|
1
|
+
import { MemcacheCache, MemoryCache, RedisCache } from '../adapters/index.js';
|
|
2
|
+
import { CACHE_ERROR_CODES, CacheError } from '../errors/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Factory for creating cache instances
|
|
8
5
|
*/
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './ICache.js';
|
|
2
|
+
export * from './ISession.js';
|
package/dist/esm/errors/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { errorMessageRegistry } from '@naman_deep_singh/errors
|
|
2
|
-
import { CACHE_ERROR_CODES } from './cacheErrorCodes';
|
|
1
|
+
import { errorMessageRegistry } from '@naman_deep_singh/errors';
|
|
2
|
+
import { CACHE_ERROR_CODES } from './cacheErrorCodes.js';
|
|
3
3
|
errorMessageRegistry.register(CACHE_ERROR_CODES);
|
|
4
|
-
export
|
|
4
|
+
export * from './CacheError.js';
|
|
5
|
+
export * from './cacheErrorCodes.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
export * from './types.js';
|
|
1
3
|
// Errors
|
|
2
|
-
export
|
|
3
|
-
//
|
|
4
|
-
export
|
|
5
|
-
//
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
//
|
|
10
|
-
export
|
|
11
|
-
// Session
|
|
12
|
-
export { SessionStore } from './session';
|
|
13
|
-
// Middleware
|
|
14
|
-
export { cacheSessionMiddleware, cacheHealthCheckMiddleware, cacheResponseMiddleware, } from './middleware/express';
|
|
4
|
+
export * from './errors/index.js';
|
|
5
|
+
// Core abstractions & interfaces
|
|
6
|
+
export * from './core/index.js';
|
|
7
|
+
// Cache adapters (Redis, Memory, Memcache)
|
|
8
|
+
export * from './adapters/index.js';
|
|
9
|
+
// Session management
|
|
10
|
+
export * from './session/index.js';
|
|
11
|
+
// Middleware integrations
|
|
12
|
+
export * from './middleware/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './cacheMiddleware.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './express/index.js';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CacheError } from '../errors';
|
|
2
|
-
import { CACHE_ERROR_CODES } from 'src/errors/cacheErrorCodes';
|
|
1
|
+
import { CACHE_ERROR_CODES, CacheError } from '../errors/index.js';
|
|
3
2
|
/**
|
|
4
3
|
* Session store wrapper around cache adapters
|
|
5
4
|
* Provides session management functionality
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './SessionStore.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseCache } from '../../core/
|
|
2
|
-
import type { HealthCheckResponse, MemcacheCacheConfig } from '../../types';
|
|
1
|
+
import { BaseCache } from '../../core/index.js';
|
|
2
|
+
import type { HealthCheckResponse, MemcacheCacheConfig } from '../../types.js';
|
|
3
3
|
export declare class MemcacheCache<T = unknown> extends BaseCache<T> {
|
|
4
4
|
private memcacheConfig;
|
|
5
5
|
private client;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MemcacheCache } from './MemcacheCache';
|
|
1
|
+
export { MemcacheCache } from './MemcacheCache.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseCache } from '../../core/
|
|
2
|
-
import type { HealthCheckResponse, MemoryCacheConfig } from '../../types';
|
|
1
|
+
import { BaseCache } from '../../core/index.js';
|
|
2
|
+
import type { HealthCheckResponse, MemoryCacheConfig } from '../../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* In-memory cache adapter for development and testing
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MemoryCache } from './MemoryCache';
|
|
1
|
+
export { MemoryCache } from './MemoryCache.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseCache } from '../../core/
|
|
2
|
-
import type { HealthCheckResponse, RedisCacheConfig } from '../../types';
|
|
1
|
+
import { BaseCache } from '../../core/index.js';
|
|
2
|
+
import type { HealthCheckResponse, RedisCacheConfig } from '../../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Redis cache adapter
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { RedisCache } from './RedisCache';
|
|
1
|
+
export { RedisCache } from './RedisCache.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BatchResult, CacheConfig, CacheStats, HealthCheckResponse } from '../types';
|
|
2
|
-
import type { ICache } from './interfaces';
|
|
1
|
+
import type { BatchResult, CacheConfig, CacheStats, HealthCheckResponse } from '../types.js';
|
|
2
|
+
import type { ICache } from './interfaces/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Abstract base class for all cache adapters
|
|
5
5
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from './ICache.js';
|
|
2
|
+
export * from './ISession.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AppError } from '@naman_deep_singh/errors
|
|
2
|
-
import type { CacheErrorCode } from './cacheErrorCodes';
|
|
1
|
+
import { AppError } from '@naman_deep_singh/errors';
|
|
2
|
+
import type { CacheErrorCode } from './cacheErrorCodes.js';
|
|
3
3
|
export declare class CacheError extends AppError {
|
|
4
4
|
readonly adapter?: string;
|
|
5
5
|
readonly operation?: string;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './CacheError.js';
|
|
2
|
+
export * from './cacheErrorCodes.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export { MemoryCache } from './adapters/memory';
|
|
8
|
-
export { CacheFactory } from './core/factory';
|
|
9
|
-
export { SessionStore } from './session';
|
|
10
|
-
export { cacheSessionMiddleware, cacheHealthCheckMiddleware, cacheResponseMiddleware, } from './middleware/express';
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './errors/index.js';
|
|
3
|
+
export * from './core/index.js';
|
|
4
|
+
export * from './adapters/index.js';
|
|
5
|
+
export * from './session/index.js';
|
|
6
|
+
export * from './middleware/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NextFunction, Request, Response } from 'express';
|
|
2
|
-
import type { ICache } from '../../core/
|
|
3
|
-
import type { SessionStore } from '../../session/
|
|
2
|
+
import type { ICache } from '../../core/index.js';
|
|
3
|
+
import type { SessionStore } from '../../session/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Express middleware for session management using cache
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './cacheMiddleware.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './express/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ICache } from '../core/
|
|
2
|
-
import type { SessionData, SessionOptions } from '../types';
|
|
1
|
+
import type { ICache } from '../core/index.js';
|
|
2
|
+
import type { SessionData, SessionOptions } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Session store wrapper around cache adapters
|
|
5
5
|
* Provides session management functionality
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type { SessionOptions } from '../types';
|
|
1
|
+
export * from './SessionStore.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naman_deep_singh/cache",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Extensible caching layer supporting Redis, Memcache, and in-memory caches with automatic fallback, namespacing, session management, and Express middleware.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -37,14 +37,16 @@
|
|
|
37
37
|
"typescript": "^5.9.3"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@naman_deep_singh/errors
|
|
41
|
-
"@naman_deep_singh/response-utils": "^2.1.4",
|
|
40
|
+
"@naman_deep_singh/errors": "^2.2.2",
|
|
42
41
|
"memcached": "^2.2.2",
|
|
43
42
|
"redis": "^4.6.10"
|
|
44
43
|
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
45
47
|
"scripts": {
|
|
46
48
|
"build": "pnpm run build:types && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json",
|
|
47
|
-
"build:types": "tsc -p tsconfig.
|
|
49
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
48
50
|
"clean": "rimraf dist"
|
|
49
51
|
}
|
|
50
52
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BaseCache } from '../../core/BaseCache';
|
|
2
|
-
import type { HealthCheckResponse, MemcacheCacheConfig } from '../../types';
|
|
3
|
-
export declare class MemcacheCache<T = unknown> extends BaseCache<T> {
|
|
4
|
-
private memcacheConfig;
|
|
5
|
-
private client;
|
|
6
|
-
private isConnected;
|
|
7
|
-
constructor(memcacheConfig: MemcacheCacheConfig);
|
|
8
|
-
connect(): Promise<void>;
|
|
9
|
-
private ensureConnected;
|
|
10
|
-
private ping;
|
|
11
|
-
exists(key: string): Promise<boolean>;
|
|
12
|
-
get(key: string): Promise<T | null>;
|
|
13
|
-
set(key: string, value: T, ttl?: number): Promise<void>;
|
|
14
|
-
delete(key: string): Promise<boolean>;
|
|
15
|
-
clear(): Promise<void>;
|
|
16
|
-
isAlive(): Promise<HealthCheckResponse>;
|
|
17
|
-
close(): Promise<void>;
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MemcacheCache } from './MemcacheCache';
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { BaseCache } from '../../core/BaseCache';
|
|
2
|
-
import type { HealthCheckResponse, MemoryCacheConfig } from '../../types';
|
|
3
|
-
/**
|
|
4
|
-
* In-memory cache adapter for development and testing
|
|
5
|
-
*/
|
|
6
|
-
export declare class MemoryCache<T = unknown> extends BaseCache<T> {
|
|
7
|
-
private memoryCacheConfig;
|
|
8
|
-
private store;
|
|
9
|
-
private cleanupInterval;
|
|
10
|
-
constructor(memoryCacheConfig: MemoryCacheConfig);
|
|
11
|
-
/**
|
|
12
|
-
* Start periodic cleanup of expired items
|
|
13
|
-
*/
|
|
14
|
-
private startCleanup;
|
|
15
|
-
/**
|
|
16
|
-
* Get a value from memory
|
|
17
|
-
*/
|
|
18
|
-
get(key: string): Promise<T | null>;
|
|
19
|
-
/**
|
|
20
|
-
* Set a value in memory
|
|
21
|
-
*/
|
|
22
|
-
set(key: string, value: T, ttl?: number): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Delete a key from memory
|
|
25
|
-
*/
|
|
26
|
-
delete(key: string): Promise<boolean>;
|
|
27
|
-
/**
|
|
28
|
-
* Check if key exists
|
|
29
|
-
*/
|
|
30
|
-
exists(key: string): Promise<boolean>;
|
|
31
|
-
/**
|
|
32
|
-
* Clear all keys with current namespace
|
|
33
|
-
*/
|
|
34
|
-
clear(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Get multiple values at once
|
|
37
|
-
*/
|
|
38
|
-
getMultiple(keys: string[]): Promise<Record<string, T | null>>;
|
|
39
|
-
/**
|
|
40
|
-
* Set multiple values at once
|
|
41
|
-
*/
|
|
42
|
-
setMultiple(data: Record<string, T>, ttl?: number): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Delete multiple keys at once
|
|
45
|
-
*/
|
|
46
|
-
deleteMultiple(keys: string[]): Promise<number>;
|
|
47
|
-
/**
|
|
48
|
-
* Increment a numeric value
|
|
49
|
-
*/
|
|
50
|
-
increment(key: string, amount?: number): Promise<number>;
|
|
51
|
-
/**
|
|
52
|
-
* Decrement a numeric value
|
|
53
|
-
*/
|
|
54
|
-
decrement(key: string, amount?: number): Promise<number>;
|
|
55
|
-
/**
|
|
56
|
-
* Check if memory cache is alive
|
|
57
|
-
*/
|
|
58
|
-
isAlive(): Promise<HealthCheckResponse>;
|
|
59
|
-
/**
|
|
60
|
-
* Close memory cache
|
|
61
|
-
*/
|
|
62
|
-
close(): Promise<void>;
|
|
63
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MemoryCache } from './MemoryCache';
|