{"id":13748926,"url":"https://github.com/Topener/To.ImageCache","last_synced_at":"2025-05-09T11:31:45.069Z","repository":{"id":36348593,"uuid":"40653346","full_name":"Topener/To.ImageCache","owner":"Topener","description":"A simple CommonJS module for Titanium to cache images a little less temporarily, and configurable","archived":false,"fork":false,"pushed_at":"2023-03-01T09:07:50.000Z","size":70,"stargazers_count":27,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-09T05:45:42.332Z","etag":null,"topics":["appcelerator","commonjs","hacktoberfest","titanium"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Topener.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-08-13T10:39:03.000Z","updated_at":"2023-03-01T09:07:56.000Z","dependencies_parsed_at":"2024-01-17T13:12:16.909Z","dependency_job_id":"6ddb97c8-ce57-4e26-a3b3-2acddb53d667","html_url":"https://github.com/Topener/To.ImageCache","commit_stats":{"total_commits":29,"total_committers":6,"mean_commits":4.833333333333333,"dds":0.1724137931034483,"last_synced_commit":"c752f4e4165ff1f3660299bb56dce5dc843f27f9"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Topener%2FTo.ImageCache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Topener%2FTo.ImageCache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Topener%2FTo.ImageCache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Topener%2FTo.ImageCache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Topener","download_url":"https://codeload.github.com/Topener/To.ImageCache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253240350,"owners_count":21876593,"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":["appcelerator","commonjs","hacktoberfest","titanium"],"created_at":"2024-08-03T07:00:52.590Z","updated_at":"2025-05-09T11:31:40.050Z","avatar_url":"https://github.com/Topener.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# To.ImageCache\nA simple CommonJS module to cache images a little less temporarily, and configurable\n\n## Setup\n\nAdd `To.ImageCache` CommonJS module to your project. Either download this project, or install using `gittio`\n\n### Through NPM\nIn classic go to the `Resources` folder, for **Alloy** go to the `lib` directory of your project, then run the following command\n\n`npm install to.imagecache`\n_Note: if your app doesn't have `node_modules` yet, run `npm init` first!_\n\n## Configuration\n\n**IMPORTANT: Version 1.0 is not backwards compatible with previous versions. Name has changed to lowercase for NPM support**\n\nThe configuration is simple: No configuration is needed, unless you want to change something. \n\nAll current properties available shown below\n\n```js\nrequire('to.imagecache').config({\n\tdebug: true, //default \"false\"\n\texpireTime: 100000, // time in seconds, default 43200 = 12 hours\n\tfolder: 'CustomFolder', // folder to store the cache in, default \"ToCache\"\n\tremoteBackup: true // iOS Only do you want the images to be backed up to iCloud?\n});\n```\n\nThe config can be changed at all times, between different files so support multiple folders, expiration times and file specfic backup properties. You only have to pass what you want to change from now on. No need to pass all config properties\n\nIf you want to make a copy of the config, so you can restore it later, use the getter\n\n```js\nvar config = require('to.imagecache').config();\n```\n\nAll available images will be stored in Properties\n\n```js\n Ti.App.Properties.getList('To.ImageCache.ImageList');\n ```\n \n There is, however, no need to call this list manually unless you really want to. Best to use build in functionality\n \n## Usage\n \n There are 2 methods to use the module. \n \n#### Only call the module when the image is needed, it will then, return a blob of the image while you wait. \n  \nNote: This might cause delays in your app and is only recommended for smaller images\n\n```js\nvar blob = require('to.imagecache').remoteImage('http://example.com/image.jpg');\n```\n\nThis will cache the image the first time it is called, and the next time you request this same file it will return the same blob, but this time stored locally\n\n#### Pre-cache images before they are needed\n\nThis method is preferred for bigger images, as this can happen in the background\n\n```js\nrequire('to.imagecache').cache('http://example.com/image.jpg');\n```\n\nThis function will NOT return a blob, but will cache the file using `XHR`.\n\nAditonally, you can add a timeout and callback function: \n\n```js\nrequire('to.imagecache').cache('http://example.com/image.jpg', 25000, function(blob){\n\t$.imageView.image = blob;\n});\n```\n\n## Clearing Cache\n\nYou want, of course, to clear the cache when needed. This is *NOT* done automatically. \n\nThe best function to call is `flushExpired`\n\n```js\nrequire('to.imagecache').flushExpired();\n```\n\nThis function will remove all files older than the expired time.\n\nYou can also clear all cache\n\n```js\nrequire('to.imagecache').clearCache();\n```\n\nThis will remove all cached files *regardless* of expired time.\n\nYou can also remove a single file by URL:\n\n```js\nrequire('to.imagecache').removeRemote('http://example.com/image.jpg');\n```\nThis will also *NOT* take expiry time in consideration\n\nIf you know the filename (which is internally generated, so you probably won't), you can remove by filename too\n\n```js\nrequire('to.imagecache').removeFile('a128a10e623e08c9b5b704bf162d770e');\n```\n\n## Advanced\n\nYou can fetch the entire cache size, in bytes, from the module. This could, for example, be used to display users so they can be aware how much cache is present, and you could give the users the ability to remove cache manually\n\n```js\nrequire('to.imagecache').cacheSize()\n```\n\nYou can also, at a later point, update the config. Expire time is per-file, and stored per-file. So changing it later will not update the currently stored files. Might be usefull for different expiry times.\n\nAlso the folder can be changed multiple times. Folders are also stored per file, so changable all the time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTopener%2FTo.ImageCache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTopener%2FTo.ImageCache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTopener%2FTo.ImageCache/lists"}