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

[TS migration] Remove memory only keys logic #504

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1588,17 +1588,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 @@ -1681,7 +1670,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
Loading