npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

expo-cache-manager

v0.3.2

Published

Library for handling data caching for React Native with expo-cache-manager

Downloads

46

Readme

Example source code

Library for handling data caching for React Native with expo-file-system.

About

The logic of work is based on a bunch: Manager-Entry. Where manager is an abstraction over a directory within a filesystem, and entry is a file instance within that directory.

Distinctive features:

  • Quick start and flexible setting;
  • Support file expiration;
  • Support download progress;
  • Image component based on expo-image library
  • Many supported image formants
  • BlurHash support
  • A lot of action functions for manipulating the file and the cache in general;
  • Ready-made basic components;
  • Possibility of scaling.

This library contains the following:

  • React provider to initialize cache managers;
  • Ready-made React Native components for ease of development;
  • React hooks for quick integration into functional components;
  • Manager classes and entries for own cache system;
  • Utility class with useful functions.

This library is suitable for both small projects and large ones that require their own implementation of the cache.

Installation

Managed workflow

Basic dependencies

npx expo install expo-file-system expo-cache-manager

Additional dependencies

If you plan to use image or progress indicator components, then you need to install additional dependencies

npx expo install expo-image react-native-svg

Bare workflow

Basic dependencies

yarn add expo-file-system expo-cache-manager
# or
npm i expo-file-system expo-cache-manager

Follow the instructions to install expo-file-system package.

Additional dependencies

If you plan to use image or progress indicator components, then you need to install additional dependencies

yarn add react-native-svg expo-image
# or
npm i react-native-svg expo-image

Follow the instructions to install expo-image package. Follow the instructions to install react-native-svg package.

Quick start

import { CacheManagerProvider, CachingImage } from 'expo-cache-manager'

export default function App() {
  return (
    <CacheManagerProvider
      managers={[
        {
          name: 'images',
          entryExpiresIn: 30 * 24 * 60 * 60 // 1 month (in seconds)
        },
        { name: 'videos' }, // without expire prop (-1 default)
        'other' // short naming (-1 default)
      ]}
    >
      <CachingImage
        uri={'remote-file-uri'}
        manager='images'
        style={{ width: '100%', height: 300 }}
        // placeholder="LEHV6nWB2yk8pyo0adR*.7kCMdnj" // blurhash support
        // disabledActions=['pause', 'resume', 'download'] // default []
        // automatic // automatically start download. Default = true
        // indicator={false} // hide progress indicator
        // onProgress={(v) => console.log(`${v}%`)}
        // headers={{
        //   Authorization: `${token_type} ${access_token}`
        // }}

        // ...and many others options
      />
    </CacheManagerProvider>
  )
}

Cache expiration rules for entries (entryExpiresIn)

  • -1 (default) - the cache is forever
  • 0 - the cache is automatically reset on the next render
  • {seconds} - reset the cache after a certain number of seconds, after loading the file (when updating the render)

Links

Future list

  • [ ] SQLite support with queries
  • [ ] Advanced example
  • [x] More detailed documentation
  • [x] Add expire support

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT