') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); GitHub - Cynaith/Ledis: More convenient to store objects in Redis · GitHub
Skip to content

Latest commit

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Ledis

https://img.shields.io/apm/l/vim-modehttps://img.shields.io/appveyor/build/gruntjs/grunt?label=1.2.releasehttps://img.shields.io/badge/%E4%B8%AA%E4%BA%BA%E4%B8%BB%E9%A1%B5-Cynaith-green

可以对Redis直接存储对象

使用方法

中文API文档

Maven

<dependency>
<groupId>com.github.cynaith</groupId>
<artifactId>LightRedis</artifactId>
<version>1.3-RELEASE</version>
</dependency>
Ledisledis = newLedis("127.0.0.1",6379);

优化

  • List<String> scan(String prefix,String suffix);
    • 查询指定前缀后缀的value

字符串

  • List<String> mgets(String emptyValue,String... key);
    • 获取多个key,当key不存在时,返回emptyValue
  • String set(String key,Object value);
    • 插入对象
  • Object get(String key);
    • 获取对象

List

  • Long lpush(String key,Object... objects);
    • 从左边追加一个Object到list(key)中
  • Long rpush(String key,Object... objects);
    • 从右边追加一个Object到list(key)中
  • Long lrem(String key,long count,Object value);
    • 删除List(key)中的Object
  • String lset(String key,int index,Object object);
    • 修改List(key)中的Object
  • List<Object> sortObj(String key);
    • 对象排序

Set

  • Long sadd(String key, Object... objects);
    • 向Set(key)中插入对象
  • Set<Object> smember(String key);
    • 获取Set(key)中所有元素
  • Long srem(String key, Object... objects);
    • 删除key对应Set中的Object (也可以是String)
  • Object spop(String key);
    • 随机弹出一个元素 (不区分对象字符串)
  • Long smove(String key1, String key2, Object val);
    • 将元素从 key1(Set) 中移到 key2(Set) 中 (不区分对象字符串)
  • Set<Object> sinter(String key1,String key2);
    • 获取集合key1和key2的交集 (不区分对象字符串)
  • Set<Object> sunion(String key1,String key2);
    • 获取集合key1和key2的并集 (不区分对象字符串)
  • Set<Object> sdiff(String key1,String key2);
    • 获取集合key1和key2的差集 (不区分对象字符串)

Sorted Set

  • Map<String , Double> zrangeWithScores(String key, int i , int j);
    • 修改原返回值 Map -> Map<String , Double>
  • Map<String, Double> zrangByScoreWithScores(String key, double i , double j);
    • 修改原返回值 Map -> Map<String , Double>

Hash

  • String hmset(String key, Map<String,Object> map);
    • Map<String,String>和Map<byte[],byte[]>----> Map<String,Object>

      注:Object支持String,会自动转换

  • List<Object> hmget(String key,String... mapkeys);
    • 获取Hash中一个或多个元素value 包含Object和String
  • Long hset(String key, String mapkey, Object mapvalue);
    • 支持向HashMap插入Object
  • Map<String,Object> hgetAll(String key);
    • 获取全部元素k-V 包括Object和String
  • List<Object> hvals(String key);
    • 获取全部元素的value 包括Object和String

1.0-RELEASE

  • 发布基础版本

1.1-RELEASE

  • 修改for -> foreach

1.2-RELEASE

  • 修复依赖问题
  • 修复scan的bug

1.3-RELEASE

  • 整合String类型的对象插入
  • Object未序列化时,抛出运行时UnserizlizeException异常

About

More convenient to store objects in Redis

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages