Skip to content

Commit

Permalink
Merge pull request #504 from blazejkustra/chore/remove-memory-only-keys
Browse files Browse the repository at this point in the history
[TS migration] Remove memory only keys logic
  • Loading branch information
lakchote authored Mar 12, 2024
2 parents 8554793 + 9132954 commit 4193343
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 45 deletions.
14 changes: 0 additions & 14 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ value will be saved to storage after the default value.</p>
<dt><a href="#update">update(data)</a> ⇒ <code>Promise</code></dt>
<dd><p>Insert API responses and lifecycle data into Onyx</p>
</dd>
<dt><a href="#setMemoryOnlyKeys">setMemoryOnlyKeys(keyList)</a></dt>
<dd><p>When set these keys will not be persisted to storage</p>
</dd>
<dt><a href="#init">init([options])</a></dt>
<dd><p>Initialize the store with actions and listening for storage events</p>
</dd>
Expand Down Expand Up @@ -424,17 +421,6 @@ Insert API responses and lifecycle data into Onyx
| --- | --- | --- |
| data | <code>Array</code> | An array of objects with shape {onyxMethod: oneOf('set', 'merge', 'mergeCollection', 'multiSet', 'clear'), key: string, value: *} |

<a name="setMemoryOnlyKeys"></a>

## setMemoryOnlyKeys(keyList)
When set these keys will not be persisted to storage

**Kind**: global function

| Param | Type |
| --- | --- |
| keyList | <code>Array.&lt;string&gt;</code> |

<a name="init"></a>

## init([options])
Expand Down
6 changes: 0 additions & 6 deletions lib/Onyx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,6 @@ declare function init(config?: InitOptions): void;
*/
declare function hasPendingMergeForKey(key: OnyxKey): boolean;

/**
* When set these keys will not be persisted to storage
*/
declare function setMemoryOnlyKeys(keyList: OnyxKey[]): void;

/**
* Tries to get a value from the cache. If the value is not present in cache it will return the default value or undefined.
* If the requested key is a collection, it will return an object with all the collection members.
Expand All @@ -335,7 +330,6 @@ declare const Onyx: {
removeFromEvictionBlockList: typeof removeFromEvictionBlockList;
isSafeEvictionKey: typeof isSafeEvictionKey;
METHOD: typeof METHOD;
setMemoryOnlyKeys: typeof setMemoryOnlyKeys;
tryGetCachedValue: typeof tryGetCachedValue;
isCollectionKey: typeof isCollectionKey;
isCollectionMemberKey: typeof isCollectionMemberKey;
Expand Down
12 changes: 0 additions & 12 deletions lib/Onyx.js
Original file line number Diff line number Diff line change
Expand Up @@ -1609,17 +1609,6 @@ function update(data) {
return clearPromise.then(() => Promise.all(_.map(promises, (p) => p())));
}

/**
* When set these keys will not be persisted to storage
* @param {string[]} keyList
*/
function setMemoryOnlyKeys(keyList) {
Storage.setMemoryOnlyKeys(keyList);

// When in memory only mode for certain keys we do not want to ever drop items from the cache as the user will have no way to recover them again via storage.
cache.setRecentKeysLimit(Infinity);
}

/**
* Initialize the store with actions and listening for storage events
*
Expand Down Expand Up @@ -1702,7 +1691,6 @@ const Onyx = {
removeFromEvictionBlockList,
isSafeEvictionKey,
METHOD,
setMemoryOnlyKeys,
tryGetCachedValue,
hasPendingMergeForKey,
isCollectionKey,
Expand Down
3 changes: 0 additions & 3 deletions lib/storage/__mocks__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ const idbKeyvalMock: StorageProvider = {
getDatabaseSize() {
return Promise.resolve({bytesRemaining: 0, bytesUsed: 99999});
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
setMemoryOnlyKeys() {},
};

const idbKeyvalMockSpy = {
Expand All @@ -86,7 +84,6 @@ const idbKeyvalMockSpy = {
storageMapInternal = data;
}),
getDatabaseSize: jest.fn(idbKeyvalMock.getDatabaseSize),
setMemoryOnlyKeys: jest.fn(idbKeyvalMock.setMemoryOnlyKeys),
};

export default idbKeyvalMockSpy;
2 changes: 0 additions & 2 deletions lib/storage/providers/IDBKeyVal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const provider: StorageProvider = {
},
multiSet: (pairs) => setMany(pairs, getCustomStore()),
clear: () => clear(getCustomStore()),
// eslint-disable-next-line @typescript-eslint/no-empty-function
setMemoryOnlyKeys: () => {},
getAllKeys: () => keys(getCustomStore()),
getItem: (key) =>
get(key, getCustomStore())
Expand Down
3 changes: 0 additions & 3 deletions lib/storage/providers/SQLiteStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ const provider: StorageProvider = {
});
},

// eslint-disable-next-line @typescript-eslint/no-empty-function
setMemoryOnlyKeys: () => {},

// eslint-disable-next-line @typescript-eslint/no-empty-function
keepInstancesSync: () => {},
};
Expand Down
5 changes: 0 additions & 5 deletions lib/storage/providers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ type StorageProvider = {
*/
clear: () => Promise<QueryResult | void>;

/**
* Sets memory only keys
*/
setMemoryOnlyKeys: () => void;

/**
* Gets the total bytes of the database file
*/
Expand Down

0 comments on commit 4193343

Please sign in to comment.