PHP Classes

Tephlon: Store and retrieve objects in files

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 47%Total: 302 All time: 7,388 This week: 175Up
Version License PHP version Categories
tephlon 1.0MIT/X Consortium ...5.0PHP 5, Databases, Files and Folders, L..., D...
Description 

Author

This package can be used to store and retrieve objects in files or other storage container types:

It can serialize objects or other type of variable values and store them in files. It features:

- Java-style key-value maps
- Namespaces
- Codeigniter integration
- Configurable life time of records
- Multi-driver architecture (SQL, file system, etc, ...)
- Access to stored objects without using SQL
- Easy incremental backup of data with SVN/GIT

Picture of Simone Scarduzio
Name: Simone Scarduzio <contact>
Classes: 1 package by
Country: Italy Italy
Age: 40
All time rank: 3825155 in Italy Italy
Week rank: 312 Up14 in Italy Italy Up

Details

:: Tephlon PHP Persistence library :: For recent updates, documentation, examples, issue tracking and discussion please always refer to the following site: http://tephlon.googlecode.com/ Feel free to contact me if you are interested in improving this software. == Install== Typically this is the directory layout you want to keep in your Tephlon project: Your_php_project_> |_> index.php |_> css/ |_> img/ |_> Tephlon == Direct Access Usage Example== // include somewhere Tephlon script appropriately. <?php require_once("/Tephlon/Tephlon.php"); // 1. Get a Tephlon persistent resource $t = Tephlon::getResource(); // 2. Decide a label for your precious object and invoke it with retrieve $my_precious = $t->retrieve("my_precious_label"); /* If there was a cache record for "my_precious_label", now the variable $my_precious will have its content inside. If no such record was found, it's being created with value of null, and null is returned. */ // You can also specify a fallback defaul value if the record is not found (optional) // $my_precious = $t->retrieve("my_precious_label", array()); /* Doing as above is the same of doing: $my_precious = $t->retrieve("my_precious_label"); if($myprecious != null){ $my_precious = array(); } */ // 3. Now you are free to modify your "precious" variable and make it become any type, from boolean to // any class object. Once you want to save it to Tephlon persistence layer, simply do: $my_precious = functionToCalculateImportantData($x, $y); // Other business logic... // 4. Saving to persistence! $t->register($my_precious, "my_precious_label"); // Now the new value of my precious will be saved, so that next script execution (read: page visit) will have that // content. // You can also specify a lifetime (in seconds) for this record. For example: // For example here, the content will be available for the next 24h $t->register($my_precious, "my_precious_label", 24*60*60); == Using TMap Data Structure == Note: refer to Twitter example and TMapTest.php for complete reference TMap is a wrapper class against the core I/O API of Tephlon's persistence engine. It works as Java's Map interface, implementing almost all methods: (get(key), put(key, value), clear(), values(), keys(), etc). but also a new one, which makes sense in PHP: getAll() which returns all the content of the map as an associative array. <?php // 1. include somewhere Tephlon script appropriately. require_once("/Tephlon/Tephlon.php"); // 2.a Initialize the TMap into global namespace. $map = new TMap(); // Now if you already executed the script, the map will already contain keys and values!!! // 2.b Initialize TMap specifying a namespace (some examples) $map = new TMap("myUsers"); $map = new TMap("posts_from_user_" . $userID); $map = new TMap("recent_comments"); // Now if you already executed the script, the map will already contain keys and values!!! /* NOTE: a namespace can set also passing an object, though this practice is quite risky since it can make your content unreachable if you do it wrong. */ // 3. Put some value (some examples) $map->put("key1", "some_string"); $map->put(time(), new Post($userID, $content); // 4. Modifying content of records $map->put("key1", "this_string_is_better"); // 5. Retrieve it $var = $map->get("key1"); $theUser = $map->get($requestedUser); $theUser->setEmail("new@email.com"); $map->put($requestedUser, $theUser); Enjoy! Simone

Screenshots  
  • Logo
  Files folder image Files  
File Role Description
Files folder imageconfig (1 file)
Files folder imageDataStructures (2 files)
Files folder imagelib (4 files)
Plain text file LICENSE.txt Lic. MIT license
Plain text file README.txt Doc. Install and use Tephlon
Plain text file Tephlon.php Class Main class

  Files folder image Files  /  config  
File Role Description
  Plain text file tephlon_config.php Conf. Settings

  Files folder image Files  /  DataStructures  
File Role Description
  Plain text file TephlonType.php Class Data structure superclass
  Plain text file TMap.php Class A data structure resembling Java's Map interface

  Files folder image Files  /  lib  
File Role Description
  Plain text file FileResource.php Class Driver for file based persistence
  Plain text file Logger.php Class Logging utility
  Plain text file PersistenceEngine.php Class Common operations for persistence
  Plain text file Record.php Class Internal data type

 Version Control Unique User Downloads Download Rankings  
 0%
Total:302
This week:0
All time:7,388
This week:175Up
 User Ratings  
 
 All time
Utility:68%StarStarStarStar
Consistency:68%StarStarStarStar
Documentation:62%StarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:47%StarStarStar
Rank:2996