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

com.dss.caching

v1.1.3

Published

A collection of useful Unity extensions and utilities.

Downloads

4

Readme

caching

An image, string, and audio clip caching system for Unity.

The first time you "request" a url from the cache, it downloads it and stores a copy on-disc (in Application.persistentDataPath and in-memory). Future "requests" use the in-memory version (if it has already been loaded), or the on-disc version (which then gets stored in-memory for faster access in the future).

How To Install

The caching package uses the scoped registry feature to import dependent packages. Please add the following sections to the package manifest file (Packages/manifest.json).

To the scopedRegistries section:

{
    "name": "DSS",
    "url": "https://registry.npmjs.com",
    "scopes": [ "com.dss" ]
}

To the dependencies section:

"com.dss.core-utils": "1.6.6",
"com.dss.caching": "1.1.3"

After changes, the manifest file should look like below:

{
    "scopedRegistries": [
    {
        "name": "DSS",
        "url": "https://registry.npmjs.com",
        "scopes": [ "com.dss" ]
    }
    ],
    "dependencies": {
        "com.dss.core-utils": "1.6.6",
        "com.dss.caching": "1.1.3"
        ...

Usage

The Cache component can be accessed as a singleton from any script as follows:


// Grab a reference to the singleton
DSS.Caching.Cache cache = DSS.Caching.Cache.Instance;

// Request a sprite from the given url
cache.RequestSprite("https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
(Sprite sprite) =>
{
    // Do something with the sprite once it loads
},
(string errorMessage) =>
{
    Debug.LogError(errorMessage);
});

// Request text content from the given url
cache.RequestString("https://raw.githubusercontent.com/github/gitignore/master/Unity.gitignore",
(string text) =>
{
    Debug.Log(text);
},
(string errorMessage) =>
{
    Debug.LogError(errorMessage);
});

// Request an audio clip from the given url
cache.RequestAudioClip("https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3",
(AudioClip clip) =>
{
    // Do something with the clip once it loads
},
(string errorMessage) =>
{
    Debug.LogError(errorMessage);
});

Alternatively, if you want to download a collection of files and be notified when all downloads are complete, you can do the following:


// Create a new download manager
DSS.Caching.DownloadManager dm = new DSS.Caching.DownloadManager();

// Add files to download to the manager
dm.AddSprite("https://www.example.com/A.png",
(sprite) =>
{
    // do something with sprite A
},
(error) =>
{
    Debug.LogError(error);
});

dm.AddSprite("https://www.example.com/B.png",
(sprite) =>
{
    // do something with sprite B
},
(error) =>
{
    Debug.LogError(error);
});

dm.AddSprite("https://www.example.com/C.png",
(sprite) =>
{
    // do something with sprite C
},
(error) =>
{
    Debug.LogError(error);
});

// And actually begin downloading
dm.Download(() =>
{
    Debug.Log("all files downloaded!");
});