{"id":20014762,"url":"https://github.com/willmendesneto/angular-keepit","last_synced_at":"2025-03-02T02:41:18.738Z","repository":{"id":16906302,"uuid":"19667310","full_name":"willmendesneto/angular-keepit","owner":"willmendesneto","description":"This modules is an impersonalization layer for using cache/memoization in angular JS.","archived":false,"fork":false,"pushed_at":"2014-05-09T12:32:22.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-12T15:24:08.703Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willmendesneto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-11T13:49:54.000Z","updated_at":"2015-08-25T14:02:30.000Z","dependencies_parsed_at":"2022-08-26T03:41:56.759Z","dependency_job_id":null,"html_url":"https://github.com/willmendesneto/angular-keepit","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willmendesneto%2Fangular-keepit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willmendesneto%2Fangular-keepit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willmendesneto%2Fangular-keepit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willmendesneto%2Fangular-keepit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willmendesneto","download_url":"https://codeload.github.com/willmendesneto/angular-keepit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241451545,"owners_count":19964899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T07:43:50.209Z","updated_at":"2025-03-02T02:41:18.718Z","avatar_url":"https://github.com/willmendesneto.png","language":"JavaScript","readme":"angular-keepit\n==============\n\nThis module is an impersonalization layer for using cache/memoization in angular JS.\n\n## How is it different from caching other modules? \n\nThis module provides an interface for other modules to extend the way the data is kept.\nFor now there is two different ways to keep data: angular's CacheFactory (IN MEMORY) and native localStorage (PERSISTANT).\n\nIt also provides a layer for implemeting a TTL which can be configured to be invalidated using a \"cron\" or it can be checked every time the cache is accessed.\n\nA CacheInterface enhances any module that implements it to be able to use TTL.\n\n## How does it work ?\n\nInclude keepit as a dependency of your app, and also the caching modules you want to enable.\nAt configuration runtime, the included cache modules will register themselves to KeepIt saying to which cache type they belong (MEMORY,PERSITENT,SESSION).\n\nIn your app, you inject keepit and use it like this:\n```javascript\n  var data,\n  //instanciate module if not existing, else returns the existing module\n  myCacheModule = KeepIt.getModule('SomeCacheID',KeepIt.types.MEMORY); \n  \n  data = myCacheModule.getValue(\"myData\");\n  \n  if ( data === null){\n    //inexistant or expired cache\n    data = WhateverRoutine.getData();\n    myCacheModule.put(\"myData\",data,300);//put the data in cache for 300 seconds\n  }\n  [...]\n```\n\nIf kept data you want to keep isbound to a scope, it can be automatically refreshed. \nIn your controller:\n```javascript\n  myCacheModule = KeepIt.getModule('SomeCacheID',KeepIt.types.PERSITENT); \n  $scope.whateverModel = myCacheModule.getValue(\"myCacheKey\");\n  myCacheModule.syncToModel(\"myCacheKey\",$scope,\"whateverModel\");\n  \n```\nIn background, all it does is creating a $watch expression on the scope and update the cache accordingly. It cannot use objects with deep monitoring right now, this as to be implemented/tested.\n\n## What is necessary to create my own cache interface?\n\nlook for [KeepItCacheFactoryService.js](src/Interfaces/KeepItCacheFactoryService.js) which is one of the simplest implementation I have, and it uses $cacheFactory which is well known to angular enthousiasts.\n\n#Configurations\nTODO\n\nExpire method (on the fly, timed)\nExpire check delay\n\n\n#Limitations\n\nAs it is right know, there is no implementation of cache interface returning promises, which would allow you to have an external asynchroous service to store/retrieve values. This would be theoratically possible if the module retunrns promises as values, and the code calling it know that it's a promise. Doing so would probably work but beats the goal of having an uniformized way of using cache interfaces. This still need some thinking if it was to be implemented in the future. (I could always return promises but this would remove the simplicity of usage).\n\n#API Documentation\nTODO \n\n#Cache Interface Documentation \nTODO\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillmendesneto%2Fangular-keepit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillmendesneto%2Fangular-keepit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillmendesneto%2Fangular-keepit/lists"}