How to use the @wora/cache-persist/lib/idbstorage.create function in @wora/cache-persist

To help you get started, we’ve selected a few @wora/cache-persist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github morrys / wora / packages / relay-offline / src / EnvironmentIDB.ts View on Github external
recordSourceOptions: CacheOptions = {},
        storeOptions: {
            persistOptions?: CacheOptionsStore;
            gcScheduler?: Scheduler;
            operationLoader?: OperationLoader;
            getDataID?: any; // do not use
        } = {},
        offlineStoreOptions: CacheOptions = {},
    ): RelayModernEnvironment {
        let idbStore: CacheOptions;
        let idbRecords: CacheOptions;
        let idbOffline: CacheOptions;
        const { gcScheduler, operationLoader, getDataID, persistOptions } = storeOptions;
        if (typeof window !== 'undefined') {
            const { name = 'relay', onUpgrade, version } = idbOptions;
            const idbStorages: ICacheStorage[] = IDBStorage.create({
                name,
                storeNames: ['store', 'records', 'offline'],
                onUpgrade,
                version,
            });

            idbStore = {
                storage: idbStorages[0],
                serialize: false,
                prefix: null,
                ...persistOptions,
            };

            idbRecords = {
                storage: idbStorages[1],
                serialize: false,
github morrys / wora / packages / cache-persist / examples / react-example / src / index.tsx View on Github external
const CacheLocalNew = new Cache({
    errorHandling: (error) => { 
        console.log("error", error);
        return true;
    },
    layers: [filterPersistReplace],
    prefix: 'cachenew',
});

const CacheSessionNew = new Cache({
    prefix: 'cachenew',
    webStorage: 'session'
});

const idbStorages: CacheStorage[] = IDBStorage.create( {
    name: "cache",
    onUpgrade: (db, oldv, newv, transaction) => { 
        console.log("onUpgrade", db, oldv, newv, transaction);
    }, 
    storeNames: ["persist", "persist2"],
    version: 1,
    
});

const idbStorageNo: CacheStorage[] = IDBStorage.create( {
    name: "nocache",
    onUpgrade: (db, oldv, newv, transaction) => { 
        console.log("onUpgrade", db, oldv, newv, transaction);
    }, 
    storeNames: ["persist"],
    version: 1,
github morrys / wora / packages / cache-persist / examples / react-example / src / index.tsx View on Github external
const CacheSessionNew = new Cache({
    prefix: 'cachenew',
    webStorage: 'session'
});

const idbStorages: CacheStorage[] = IDBStorage.create( {
    name: "cache",
    onUpgrade: (db, oldv, newv, transaction) => { 
        console.log("onUpgrade", db, oldv, newv, transaction);
    }, 
    storeNames: ["persist", "persist2"],
    version: 1,
    
});

const idbStorageNo: CacheStorage[] = IDBStorage.create( {
    name: "nocache",
    onUpgrade: (db, oldv, newv, transaction) => { 
        console.log("onUpgrade", db, oldv, newv, transaction);
    }, 
    storeNames: ["persist"],
    version: 1,
    
});

console.log(idbStorages[0]);

console.log(idbStorages);

const CacheLocalIDBNO = new Cache({
    prefix: null,
    serialize: false,
github morrys / wora / packages / apollo-offline / src / ApolloClientIDB.ts View on Github external
} = {},
    ): ApolloClientOffline {
        const { cacheOptions, persistOptions = {}, offlineStoreOptions = {}, idbOptions = {} } = options;
        const idbStore: CacheOptions = {
            serialize: false,
            prefix: null,
            ...persistOptions,
        };
        const idbOffline: CacheOptions = {
            serialize: false,
            prefix: null,
            ...offlineStoreOptions,
        };
        if (typeof window !== 'undefined') {
            const { name = 'apollo', onUpgrade, version } = idbOptions;
            const idbStorages: Array = IDBStorage.create({
                name,
                storeNames: ['store', 'offline'],
                onUpgrade,
                version,
            });

            idbStore.storage = idbStorages[0];
            idbOffline.storage = idbStorages[1];
        }

        const cache = new ApolloCache(cacheOptions, idbStore);
        return new ApolloClientOffline({ ...config, cache }, idbOffline);
    }
}