Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB Cache Manager #40

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

MongoDB Cache Manager #40

wants to merge 10 commits into from

Conversation

anversoft
Copy link
Contributor

I moved everything about the cache to the Mongo database so that any validation servers can be synchronized on a single database, the only substantial difference is that now the Service.updateAll(crl?: CRL, cache?: Cache) and Service.setUp(crl?: CRL, cache?: Cache) entries accept a custom Cache object as an optional second argument.

export interface Cache {
    /**
    * Setup your Cache here (database/file init)
    */
    setUp(): Promise<void>;

    /**
    * Check if the Cache Manager is set up
    */
    checkCacheManagerSetUp(): Promise<void>;

    /**
    * Check if the CRL Manager is set up
    */
    checkCrlManagerSetUp(): Promise<void>;

    /**
    * Check if the Cache Manager is ready
    */
    isReady(): Promise<boolean>;

    /**
    * Store the CRL status
    */
    storeCRLStatus(chunk: Number, totalChunk: Number, version: Number, targetVersion: Number): Promise<void>;

    /**
    * Store the Rules
    */
    storeRules(data: String): Promise<void>;

    /**
    * Store the Signatures List
    */
    storeSignaturesList(data: String): Promise<void>;

    /**
    * Store the Signatures
    */
    storeSignatures(data: String): Promise<void>;

    /**
    * Store the downlaoded UVCI
    */
    storeCRLRevokedUVCI(revokedUvci: Array<String>, deletedRevokedUvci: Array<String>): Promise<void>

    /**
    * Get the CRL Status
    */
    getCRLStatus(): Promise<CRLStatus>;

    /**
    * Get the rules
    */
    getRules(): Promise<Array<Rule>>;

    /**
    * Get the signature list
    */
    getSignatureList(): Promise<Array<Signatures>>;

    /**
    * Get the signatures
    */
    getSignatures(): Promise<SignaturesList>;

    /**
    * Check if the CRL needs to be updated
    */
    needCRLUpdate(): Promise<boolean>;

    /**
    * Check if the Rules needs to be updated
    */
    needRulesUpdate(): Promise<boolean>;

    /**
    * Check if the Signatures needs to be updated
    */
    needSignaturesUpdate(): Promise<boolean>;

    /**
    * Check if the Signature list needs to be updated
    */
    needSignaturesListUpdate(): Promise<boolean>;

    /**
    * Check if the UVCI is revoked
    */
    isUVCIRevoked(uvci: String): Promise<boolean>;

    /**
    * Close all connections
    */
    tearDown(): Promise<void>;

    /**
    * Clean the CRL
    */
    cleanCRL(): Promise<void>;


}

@anversoft
Copy link
Contributor Author

To reuse the old caching method just create a new file and copy the contents of ./src/cache.js and create a new class while calling the methods listed above

@codecov
Copy link

codecov bot commented Mar 18, 2022

Codecov Report

Merging #40 (3469ed5) into master (6326798) will decrease coverage by 1.17%.
The diff coverage is 95.42%.

@@            Coverage Diff             @@
##           master      #40      +/-   ##
==========================================
- Coverage   98.44%   97.26%   -1.18%     
==========================================
  Files           8        9       +1     
  Lines         513      659     +146     
==========================================
+ Hits          505      641     +136     
- Misses          8       18      +10     
Impacted Files Coverage Δ
src/cache.js 93.75% <78.57%> (-6.25%) ⬇️
src/service.js 93.54% <91.17%> (-2.40%) ⬇️
src/mongocache.js 98.14% <98.14%> (ø)
src/index.js 100.00% <100.00%> (ø)
src/validator.js 98.30% <100.00%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6326798...3469ed5. Read the comment docs.

@anversoft
Copy link
Contributor Author

anversoft commented Mar 18, 2022

Edit, to reuse the old method just use Service.updateAll(null, new FileCache()) everytime

@astagi
Copy link
Member

astagi commented Apr 19, 2022

Really cool feature @anversoft I need to review it deeply. I suppose this feature resolves #23, does it? cc @albertorizzi

@astagi astagi self-requested a review April 19, 2022 07:12
@astagi astagi linked an issue Apr 19, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement cache manager
2 participants