百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
K

Kizzy

> 编程语言
开源

本地存储实用程序

195 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

本地存储实用程序

Kizzy - a Local Storage Utility

Kizzy is a light-weight, cross-browser, JavaScript local storage utility. It leverages the HTML5 localStorage API when available, as well as Internet Explorer's persistent XML store — wrapped up in a easy to use, memcached-like interface. When neither of these features are available (unlikely), it falls back to an in-browser object store.

It looks like this

javascript
var cache = kizzy('users')
var agent = cache.get('Agent')
if (agent) {
  alert('Welcome back ' + agent.name)
} else {
  cache.set('Agent', {
    name: 'Agent Diaz'
  })
}

Furthermore, a call to 'set' will return the value, making it quite easy for assignment.

javascript
var cache = kizzy('users')
var agent = cache.get('Agent') || cache.set('Agent', {
  name: 'Agent Diaz'
})

Lastly, you can pass an optional third argument to 'set' that tells the cache how long to live

javascript
var cache = kizzy('users')

var agent = cache.get('Agent') || cache.set('Agent', {
  name: 'Agent Diaz'
}, 5000) // time to live set for 5 seconds

// wait 3 seconds...
setTimeout(function() {
  alert('Still there ' + cache.get('Agent').name)
}, 3000)

// 6 seconds later...
setTimeout(function() {
  cache.get('Agent').name // => expired
}, 6000)

Browser support

  • Internet Explorer 6+
  • Firefox 2+ (when localStorage is enabled (the browser default))
  • Chrome
  • Safari 4+
  • Opera

Building Kizzy

bash
$ submodule update --init
& make

Running tests

Tests will not currently pass if run on a file:/// protocol. Otherwise...

bash
$ open tests/test.html

Ender integration

Install Kizzy as an Ender module

bash
$ ender add kizzy

Use it as such:

javascript
$.cache('user').get('name')

Kizzy whu?

The name comes from Kunta Kinte, a Mandinka African warrior from the 1700's. After being brought into slavery, he had a daughter whom he named Kizzy, which translates to stay put in hopes that the family would stay together, but not stay a slave.

Happy Caching!

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言