UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Rp/TkxoQfQmcG5myZDSFfzMHh+m1SbaFxlhNpV+mjXU=' 
WHERE 
  key_id = '44633b0a017574738371e80f38103145a5310ba61244c1002157e69f1dc94642' 
  AND (
    token = 'Rp/TkxoQfQmcG5myZDSFfzMHh+m1SbaFxlhNpV+mjXU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00052