UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'sG3E9Qd+SfgLlLXhYrVxNMbQ+eZcs8YEOy4Pgamcwpw=' 
WHERE 
  key_id = 'c138eedc476cfbb90c2d875548d950c9f6738e277a5c5da8b3195879f83e7179' 
  AND (
    token = 'sG3E9Qd+SfgLlLXhYrVxNMbQ+eZcs8YEOy4Pgamcwpw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00045