Latest 1.0.1
Homepage https://github.com/REN-LEI/RENCache
License MIT
Platforms ios 7.0, requires ARC
Frameworks Foundation, UIKit
Authors

CocoaPods

  • Podfile 里添加以下依赖:
pod 'RENCache', '~> 1.0.1'
  • 运行 pod install

使用

/// 默认缓存过期时间无限,可设置默认缓存时长(秒)
@property(nonatomic) NSTimeInterval defaultTimeoutInterval;
/// 内存中最大保存个数,默认为10
@property(nonatomic) NSInteger defaultCacheMemoryLimit;

/// 单利
+ (RENCache *)sharedGlobalCache;

/// 获取磁盘缓存所有key
- (NSArray *)allKeys;

/// 判断key是否有对应缓存
- (BOOL)hasCacheForKey:(NSString *)key;

/// 获取磁盘缓存个数
- (NSUInteger)getAllCacheCount;
/// 获取磁盘全部缓存大小
- (NSUInteger)getAllCacheSize;
/// 获取单个缓存的大小
- (NSUInteger)getSingleCacheSizeForKey:(NSString *)key;

/// 清除全部缓存(包括内存中的缓存)
- (void)clearAllCache;
/// 删除内存中的缓存
- (void)clearMemoryCache;
/// 删除单个缓存
- (void)removeCacheForKey:(NSString *)key;

/// 根据key读取写入的image
- (UIImage *)imageObjectForKey:(NSString *)key;
/// 根据key写入image
- (void)setImage:(UIImage *)image forKey:(NSString *)key;
/// 根据key写入image  @param timeoutInterval 设置缓存时长(秒)
- (void)setImage:(UIImage *)image forKey:(NSString *)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;

/// 根据key读取value  @note 当获取对象是model时,model必须实现NSCoding协议
- (id)objectForKey:(NSString *)key;
/// 根据key写入value  @note 当value为自定义对象,必须实现NSCoding协议
- (void)setObjectValue:(id)value forKey:(NSString *)key;
/// 根据key写入value  @param timeoutInterval 设置缓存时长(秒) @note 当value为自定义对象,必须实现NSCoding协议
- (void)setObjectValue:(id)value forKey:(NSString *)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;

Latest podspec

{
    "name": "RENCache",
    "version": "1.0.1",
    "summary": "iOS u6587u4ef6u7f13u5b58u7c7bu5e93uff0cu652fu6301u5185u5b58u7f13u5b58u548cu7f13u5b58u8fc7u671f",
    "homepage": "https://github.com/REN-LEI/RENCache",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "renlei": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/REN-LEI/RENCache.git",
        "tag": "1.0.1"
    },
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "source_files": "RENCache/**/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This