# extendify/3.0.6/src/Shared/state/unsplash-cache.js

Extendify, version 3.0.6. 21 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.0.6/code/src/Shared/state/unsplash-cache.js
- Raw: https://pluginprobe.com/plugins/extendify/3.0.6/raw/src/Shared/state/unsplash-cache.js
- Modified: 2026-02-18T22:27:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.0.6/code/src/Shared/state/unsplash-cache.js#L10-L20`.

```javascript
import { create } from 'zustand';
import { createJSONStorage, devtools, persist } from 'zustand/middleware';

const ONE_WEEK_IN_MILLISECONDS = 1000 * 60 * 60 * 24 * 7;

const state = (set, get) => ({
	images: [],
	expiration: 0,
	isEmpty: () => get().images.length === 0,
	hasExpired: () => Date.now() > get().expiration,
	updateCache: (images) =>
		set({ images, expiration: Date.now() + ONE_WEEK_IN_MILLISECONDS }),
});

export const useUnsplashCacheStore = create(
	persist(devtools(state, { name: 'Extendify Unsplash Images' }), {
		name: `extendify-unsplash-images-${window.extSharedData.siteId}`,
		storage: createJSONStorage(() => localStorage),
	}),
);

```
