UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'xx0PUun/Au2fdizjrKqYOjJ4BIMbw3ZTrfOEWoyb+dU=' 
WHERE 
  key_id = '987bfbbbfd49a905e6b293dfb4bdb0e65b31839d5471aa583b0aa8fd59aa743d' 
  AND (
    token = 'xx0PUun/Au2fdizjrKqYOjJ4BIMbw3ZTrfOEWoyb+dU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00042