<commit_before>component extends="org.lucee.cfml.test.LuceeTestCase"{

	variables.cacheName='memcached';

	public function setUp(){
		variables.has=defineCache();
	}

	public boolean function isNotSupported() {
		if(isNull(variables.has)) setUp();
		return !variables.has;
	}

	function run( testResults , testBox ) {
		describe( "Test suite for LDEV-1210", function() {
			it( title='Checking to cache string using Memcached extension', skip=isNotSupported(), body=function( currentSpec ) {
				var testString = 'This is a test string';
				cachePut(id:'testStr', value:testString, cacheName:variables.cacheName);
				var cachedString = cacheget(id:'testStr', cacheName:variables.cacheName);
				var result = "";

				try{
					result=cachedString;
				}catch(any e){
					result=e.message;
				}

				expect(result).toBe("This is a test string");
			});

			it( title='Checking to cache query using Memcached extension', skip=isNotSupported(), body=function( currentSpec ) {
				var testQuery = queryNew("name,age","varchar,numeric",{name:["user1","user2"],age:[15,20]});
				cachePut(id:'testQry', value:testQuery, cacheName:variables.cacheName);
				var cachedQuery = cacheget(id:'testQry', cacheName:variables.cacheName);
				var result = "";

				try{
					result=cachedQuery.name[1];
				}catch(any e){
					result=e.message;
				}

				expect(result).toBe("user1");
			});
		});
	}

	private boolean function defineCache(){
		try {
			application action="update"
				caches="#{memcached:{
						  class: 'org.lucee.extension.io.cache.memcache.MemCacheRaw'
						, bundleName: 'memcached.extension'
						, bundleVersion: '172.16.58.3'
						, storage: false
						, custom: {
							'socket_timeout':'30',
							'initial_connections':'1',
							'alive_check':'true',
							'buffer_size':'1',
							'max_spare_connections':'32',
							'storage_format':'Binary',
							'socket_connect_to':'3',
							'min_spare_connections':'1',
							'maint_thread_sleep':'5',
							'failback':'true',
							'max_idle_time':'600',
							'max_busy_time':'30',
							'nagle_alg':'true',
							'failover':'true',
							'servers':'localhost:11211'
						}
						, default: ''
					}}#";
			return true;
		}
		catch(e) {}
		return false;
	}
}<commit_msg>improve test case in las memached is not available<commit_after>component extends="org.lucee.cfml.test.LuceeTestCase"{

	variables.cacheName='memcached';

	public function setUp(){
		variables.has=defineCache();
	}

	public boolean function isNotSupported() {
		if(isNull(variables.has)) setUp();
		return !variables.has;
	}

	function run( testResults , testBox ) {
		describe( "Test suite for LDEV-1210", function() {
			it( title='Checking to cache string using Memcached extension', skip=isNotSupported(), body=function( currentSpec ) {
				var testString = 'This is a test string';
				cachePut(id:'testStr', value:testString, cacheName:variables.cacheName);
				var cachedString = cacheget(id:'testStr', cacheName:variables.cacheName);
				var result = "";

				try{
					result=cachedString;
				}catch(any e){
					result=e.message;
				}

				expect(result).toBe("This is a test string");
			});

			it( title='Checking to cache query using Memcached extension', skip=isNotSupported(), body=function( currentSpec ) {
				var testQuery = queryNew("name,age","varchar,numeric",{name:["user1","user2"],age:[15,20]});
				cachePut(id:'testQry', value:testQuery, cacheName:variables.cacheName);
				var cachedQuery = cacheget(id:'testQry', cacheName:variables.cacheName);
				var result = "";

				try{
					result=cachedQuery.name[1];
				}catch(any e){
					result=e.message;
				}

				expect(result).toBe("user1");
			});
		});
	}

	private boolean function defineCache(){
		try {
			application action="update"
				caches="#{memcached:{
						  class: 'org.lucee.extension.io.cache.memcache.MemCacheRaw'
						, bundleName: 'memcached.extension'
						, bundleVersion: '3.0.2.29'
						, storage: false
						, custom: {
							'socket_timeout':'30',
							'initial_connections':'1',
							'alive_check':'true',
							'buffer_size':'1',
							'max_spare_connections':'32',
							'storage_format':'Binary',
							'socket_connect_to':'3',
							'min_spare_connections':'1',
							'maint_thread_sleep':'5',
							'failback':'true',
							'max_idle_time':'600',
							'max_busy_time':'30',
							'nagle_alg':'true',
							'failover':'true',
							'servers':'localhost:11211'
						}
						, default: ''
					}}#";
			cachePut(id='abcd', value=1234, cacheName='memcached');
			return !isNull(cacheget(id:'abcd', cacheName:'memcached'));
		}
		catch(e) {}
		return false;
	}
}
{'fraction_non_alphanumeric': 0.1592767972449419, 'fraction_numerical': 0.017003874300473527, 'mean_word_length': 3.647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2728802', 'n_tokens_mistral': 2010, 'n_tokens_neox': 1482, 'n_words': 270}