Skip to content

Commit

Permalink
Update the function names
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco5dev committed Jul 29, 2024
1 parent e6c4c76 commit 97b0b8b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/adapters/cache.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,20 @@ export class CacheAdapter extends EventEmitter implements ICacheAdapter {
}

/**
* Destroy a cache entry by key
* drop a cache entry by key
* @param {string} key - The key of the cache entry
* @returns {Promise<AdapterResults>} - A Promise that resolves when the cache entry is destroyed
* @returns {Promise<AdapterResults>} - A Promise that resolves when the cache entry is droped
*/
public async destroy(key: string): Promise<AdapterResults> {
public async drop(key: string): Promise<AdapterResults> {
if (this.cache.has(key)) {
this.cache.delete(key);
logSuccess({
content: `Cache entry ${key} destroyed`,
content: `Cache entry ${key} droped`,
devLogs: this.devLogs,
});
return {
acknowledged: true,
message: `Cache entry ${key} destroyed`,
message: `Cache entry ${key} droped`,
};
} else {
return {
Expand Down
22 changes: 11 additions & 11 deletions src/adapters/session.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export class sessionAdapter extends EventEmitter implements ISessionAdapter {
*/
constructor(
options: AdapterSetting & {
secure: SecureSystem;
maxSize?: number;
ttl?: number;
useMemory?: boolean;
}
},
key: SecureSystem
) {
super();
this.devLogs = options.devLogs;
this.secure = options.secure;
this.secure = key;
this.dataPath = options.dataPath || "./sessions";
this.maxSize = options.maxSize || 1000;
this.ttl = options.ttl || 0;
Expand Down Expand Up @@ -218,24 +218,24 @@ export class sessionAdapter extends EventEmitter implements ISessionAdapter {
}

/**
* Destroy a session by ID
* drop a session by ID
* @param {string} sessionId - The session ID
* @returns {Promise<AdapterResults>} - A Promise that resolves when the session is destroyed
* @returns {Promise<AdapterResults>} - A Promise that resolves when the session is droped
*/
public async destroy(sessionId: string): Promise<AdapterResults> {
public async drop(sessionId: string): Promise<AdapterResults> {
this.sessions.delete(sessionId);
const sessionFilePath = this.getSessionFilePath(sessionId);

try {
if (fs.existsSync(sessionFilePath)) {
fs.unlinkSync(sessionFilePath);
logSuccess({
content: `Session ${sessionId} destroyed`,
content: `Session ${sessionId} droped`,
devLogs: this.devLogs,
});
return {
acknowledged: true,
message: `Session ${sessionId} destroyed`,
message: `Session ${sessionId} droped`,
};
} else {
return {
Expand All @@ -245,12 +245,12 @@ export class sessionAdapter extends EventEmitter implements ISessionAdapter {
}
} catch (err) {
logError({
content: `Failed to destroy session ${sessionId}: ${err}`,
content: `Failed to drop session ${sessionId}: ${err}`,
devLogs: this.devLogs,
});
return {
acknowledged: false,
errorMessage: `Failed to destroy session ${sessionId}: ${err}`,
errorMessage: `Failed to drop session ${sessionId}: ${err}`,
};
}
}
Expand Down Expand Up @@ -291,7 +291,7 @@ export class sessionAdapter extends EventEmitter implements ISessionAdapter {
* Get statistics about the session store
* @returns {Promise<AdapterResults>} - A Promise that resolves with session statistics
*/
public async getStatistics(): Promise<AdapterResults> {
public async stats(): Promise<AdapterResults> {
try {
const files = fs.readdirSync(this.dataPath);
return {
Expand Down

0 comments on commit 97b0b8b

Please sign in to comment.