Skip to content

Commit

Permalink
Cleaned up emblem cache manager. Updated readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
csnv committed Dec 27, 2022
1 parent b2ee9b7 commit 5b8edd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ For a more functional, feature rich, better security and better performance solu
> Webserver running on port 82
## Features
- Token authentication.
- Emblem upload/download with transparency checks for both BMP and GIF formats.
- User config and char config saving/loading.

## Pending
- Merchant store functionality
- Merchant store functionality.

## Contributing
- Clone the repo.
- Make some changes.
- Upload to your repo.
- Open a pull request.

## Ideas, suggestions, bugs...
Please use the issues tab here in Github, your feedback is appreciated!
12 changes: 3 additions & 9 deletions utils/emblem-cache-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ import { EmblemCacheGroup } from "../models/emblemCache";
export namespace EmblemCacheManager {
// Main cache
const cache: EmblemCacheGroup = {};
// Last time cache was cleaned
const cacheLastCheck = 0;
// Remove cached emblems from memory if not requested in a certain time
const CACHE_REMOVAL_TIME = 15 * 1000; // 15 minutes
const CACHE_REMOVAL_TIME = 10 * 60 * 1000; // 10 minutes
// Interval time to perform cleanups
const CACHE_CLEAN_INTERVAL = 60 * 1000; // 1 hour
const CACHE_CLEAN_INTERVAL = 5 * 60 * 1000; // 5 minutes

/**
* Initialize interval for cleaning up cache
*/
export const init = ():void => {
export const init = (): void => {
setInterval(() => clean(), CACHE_CLEAN_INTERVAL);
};

Expand Down Expand Up @@ -55,10 +53,6 @@ export namespace EmblemCacheManager {
*/
const clean = (): void => {
const now = new Date().getTime();

if (cacheLastCheck + CACHE_CLEAN_INTERVAL > now)
return; // Still not the time to do cleanups

const keys = Object.keys(cache);
let deleted = 0;

Expand Down

0 comments on commit 5b8edd5

Please sign in to comment.