UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'CYX9pSIH9I8XrOul8KlcXzGFwEPCuJOXdCv07Q+AeMA=' 
WHERE 
  key_id = 'a736e98eabae151dcd73d102b5879be7f244389baa2d13076cff06b8e2d8a014' 
  AND (
    token = 'CYX9pSIH9I8XrOul8KlcXzGFwEPCuJOXdCv07Q+AeMA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028