Skip to content

Feature: getDiskCacheSize and getMemoryCacheSize #238

@devanshsaini11

Description

@devanshsaini11

Problem Statement

Currently there's no no public API to retrieve the sizes of the in-memory and disk caches.

Proposed Solution

Implement two static methods in the FastImage module:

  • FastImage.getMemoryCacheSize(): Returns the current size of the in-memory image cache in bytes.​
  • FastImage.getDiskCacheSize(): Returns the current size of the disk image cache in bytes.

These methods would interface with the underlying Glide and SDWebImage configurations to retrieve the cache sizes.

Example Usage:

import FastImage from '@d11/react-native-fast-image';

async function logCacheSizes() {
  const memoryCacheSize = await FastImage.getMemoryCacheSize();
  const diskCacheSize = await FastImage.getDiskCacheSize();
  console.log(`Memory Cache Size: ${memoryCacheSize} bytes`);
  console.log(`Disk Cache Size: ${diskCacheSize} bytes`);
}

Alternatives Considered

No response

Additional context

  • Glide (Android): Glide's disk cache size is configurable via the DiskCacheStrategy and DiskCache interfaces.
  • SDWebImage (iOS): SDWebImage provides methods to query the size of its disk cache.

Affected Platforms

Android, iOS

Priority

Medium (would be a nice addition)

Prior Discussion

DylanVann/react-native-fast-image#828

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or requestHelp WantedIdeal for external contributorsPlatform: BothIssue on both Android and iOS platformsResolution: PR SubmitttedA pull request with a fix has been provided.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions