Skip to content

Commit

Permalink
Updated cache to use which allows for cluster and allows us to reuse …
Browse files Browse the repository at this point in the history
…the existing redis client.
  • Loading branch information
rizen committed Oct 24, 2024
1 parent e996d23 commit 5520840
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 4 additions & 7 deletions ving/cache.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Keyv from 'keyv';
import { ouch } from '#ving/utils/ouch.mjs';
import '#ving/config.mjs';
import '@keyv/redis';
import { useRedis } from '#ving/redis.mjs';
import { KeyvAnyRedis } from 'keyv-anyredis';

let cache = undefined;

Expand All @@ -14,11 +14,8 @@ export const useCache = () => {
return cache
}
const globalForKeyv = global;
const redisUrl = process.env.VING_REDIS || '';
if (!redisUrl) {
throw new Error('VING_REDIS environment variable is not set');
}
cache = globalForKeyv.keyv || new Keyv(redisUrl);
const store = new KeyvAnyRedis(useRedis());
cache = globalForKeyv.keyv || new Keyv({ store });

if (process.env.NODE_ENV !== 'production')
globalForKeyv.keyv = cache;
Expand Down
6 changes: 4 additions & 2 deletions ving/docs/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ outline: deep
## October 2024

### 2024-10-24
* Using dotenv for environment variables.
* NOTE: You will need to run `npm i` to get the new modules.
* Installed dotenv for environment variables.
* Updated the redis client to use dotenv to get the connection string.
* Updated the redis client to trap bad connection strings with an error message.
* Updated the drizzle client to use dotenv to get the connection string.
* Updated the drizzle client to trap bad connection strings with an error message.
* Fixed a potential bug where someone enters a negative page number into the paginator.
* Fixed a bug in the Pager component introduced with the upgrade to PrimeVue 4 where the default page was 0 rather than 1.
* Updated the redis client to allow for cluster.
* Installed keyv-anyredis for cache instead of @keyv/redis.
* Updated cache to use which allows for cluster and allows us to reuse the existing redis client.
* NOTE: You will need to run `npm i` to get the new modules.

### 2024-10-01
* Added colin's patch for mysql pagination.
Expand Down

0 comments on commit 5520840

Please sign in to comment.