Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Cache latest versions in Redis #50

Closed

Conversation

hiroppy
Copy link
Contributor

@hiroppy hiroppy commented Mar 23, 2016

Hello :)

issue

#35

added files

  • src/api/routes/support/redis.ts
  • src/worker/jobs/support/redis.ts

added libraries

  • lodash
  • redis

redisKey

I define redisKey is {source}:{name}

schema (version/latest)

{
  "tag": "1.5.0+20160318102130",
  "version": "1.5.0",
  "description": null,
  "compiler": null,
  "location":     "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular.d.ts#36f1d8d82f0593d839aad6944260fd19a090aa78",
  "updated": "2016-03-18T10:21:30.000Z",
  "deprecated": null
}
{
  "tag": "1.5.0+20160318102130",
  "version": "1.5.0",
  "location":   "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular.d.ts#36f1d8d82f0593d839aad6944260fd19a090aa78",
  "updated": "2016-03-18T10:21:30.000Z",
  "deprecated": null
}

in redis

...
2398) "dt:shuffle-array"
2399) "dt:definitions/unitywebapi"
2400) "npm:pretty-data"
2401) "dt:js-data/legacy/js-data"
2402) "dt:notify.js"
2403) "dt:jquery.nouislider"
2404) "dt:envify"
2405) "dt:d3"
2406) "dt:soap"

@blakeembrey In the case of undefined, a property disappears in the schema. This is because my Implementation uses JSON.stringify. When the property disappears, is the influence given?

I think that we should create the environment to write a test.

thanks.

- issue
  typings#35
- add files
  - `src/api/routes/support/redis.ts`
  - `src/worker/jobs/support/redis.ts`
- add libraries
  - `lodash`
  - `redis`
- define `redisKey`
  - {source}:{name}

acquire package info with precedence from Redis when `version/latest`
@@ -121,6 +122,16 @@ export function getMatchingVersions (source: string, name: string, version: stri
* Retrieve the latest available version.
*/
export function getLatest (source: string, name: string, version?: string) {
return getVersionInRedis(source, name).then((data) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work with the version operator. If it's in Redis, searching by version will break.

@blakeembrey
Copy link
Member

I made some comments, but I'd invert how control occurs here. Have the API check Redis first, then fallback to DB and persist the result. Only have jobs invalidating entries. This allows deployments and re-indexing to occur independent of the cache layer. Otherwise any changes in the schema need to re-index all jobs.

@hiroppy
Copy link
Contributor Author

hiroppy commented Mar 28, 2016

Thank you for posting comments :)
Because it seems to be difficult, I close this PR.

@hiroppy hiroppy closed this Mar 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants