Giter Site home page Giter Site logo

phpcache's Introduction

phpCache

PHP files Cache, Simple, Easy and Fast Files Cache

How to use ?

include class
include('Cache/Cache.php');
to set chaced data, use set function to do that, first argument the name of cache data and the second argument the value
Cache::set('age', 35);

Cache::set('data', ['id'=>100, 'name'=>'ahmed','email'=>'[email protected]']);
to get data from cache use get function
$age = Cache::get('age');

$data = Cache::get('data');
to cache data with time, use function set with 3 arguments the thread argument is time in minuets
save cache data for one day
Cache::set('age', 100, 24*60);

$data = ['id'=>100, 'name'=>'ahmed','email'=>'[email protected]'];

Cache::set('data', $data, 24*60);
you can cache string, boolean, numbers, arrays and objects
$obj = new stdClass();

$obj->id = 200;

$obj->name = 'Ahmed';

$obj->email = '[email protected]';

Cache::set('obj', $obj);

Cache::set('sign', true);

Cache::set('num', 2015);

Cache::set('arr', [1,2,3,4]);

Cache::set('str', 'ahmed');
to save cached data forever, keep time argument empty like
Cache::set('name', 'ahmed');
to delete cached data use function delete
Cache::delete('data');
if you want to delete more than one in one line pass names as array like this
Cache::delete(['data','age','obj']);
if you want delete all Cached data you can use delete function without any arguments like
Cache::delete();
if you want to check if cached value is set or not use has function has
if(Cache::has('age'))
	echo Cache::get('age');
Have a nice Caching :)

طريقة الإستخدام

قم بتضمين الفئة
include('Cache/Cache.php');
لحفظ البيانات إستخدم الدالة
set
الوسيط الأول عبارة عن الاسم والوسيط الثاني هو للقيمة والثالث إختياري للوقت
Cache::set('age', 35);

Cache::set('data', ['id'=>100, 'name'=>'ahmed','email'=>'[email protected]']);
لجلب البيانات المحفوظة مسبقاً إستخدم الدالة
get
$age = Cache::get('age');

$data = Cache::get('data');
لحفظ البيانات لوقت محدد يمكنك إستخدام الدالة
set

#####مع وضع الزمن المراد حذف البيانات بعده كوسيط ثالث للدالة بالدقائق

المثال التالي لحفظ البيانات لمدة يوم واحد
Cache::set('age', 100, 24*60);

$data = ['id'=>100, 'name'=>'ahmed','email'=>'[email protected]'];

Cache::set('data', $data, 24*60);
يمكنك تخزين بيانات مختلفة كـ سلاسل نصية، مصفوفات، قيم منطقية، أرقام وكائنات
$obj = new stdClass();

$obj->id = 200;

$obj->name = 'Ahmed';

$obj->email = '[email protected]';

Cache::set('obj', $obj);

Cache::set('sign', true);

Cache::set('num', 2015);

Cache::set('arr', [1,2,3,4]);

Cache::set('str', 'ahmed');
لحفظ البيانات للأبد، إترك الوسيط الثالث الخاص بالوقت للدالة
set
فارغاً
Cache::set('name', 'ahmed');
لحذف قيمة مخزنة إستخدم الدالة
delete
Cache::delete('data');
لحذف مجموعة قيم دفعة واحدة قم بتمرير اسماء القيم داخل مصفوفة كوسيط لنفس الدالة
delete
Cache::delete(['data','age','obj']);

إذا أردت حذف جميع البيانات المخزنة يمكنك إستخدام نفس الدالة

delete
بدون أي وسائط
Cache::delete();

إذا أردت التحقق من وجود قيمة مخزنة مسبقاً أم لا إستخدم الدالة

has
if(Cache::has('age'))
	echo Cache::get('age');

تخزين سعيد :)

phpcache's People

Contributors

ahmedsaoud31 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.