UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'luqO+1B6ZhBGbCdXW423msntbSslRxnDQ6uA9+P+ubo=' 
WHERE 
  key_id = 'ebf3c17b787feb8a9ebbee2cf63615074783f9163b2c0f040d5df7c28ba5837a' 
  AND (
    token = 'luqO+1B6ZhBGbCdXW423msntbSslRxnDQ6uA9+P+ubo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00044